Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when unable to read a local file due to file permissions (Issue #1178) #1179

Merged
merged 4 commits into from
Dec 11, 2020

Conversation

abraunegg
Copy link
Owner

  • Fix crash when unable to read a local file due to file permissions

* Test if local file is readable based on user permissions before attempting to upload new file
* Handle same situation when performing a resync
reuse existing function
* reuse function better
* display correct filesystem error
* display correct error message when filesystem read fails
@abraunegg
Copy link
Owner Author

abraunegg commented Dec 10, 2020

Read Only File(s):

chmod 0000 *
touch *

Without PR:

Using 'user' Config Dir: /home/alex/.config/onedrive
Using 'system' Config Dir: /etc/onedrive
Configuration file successfully loaded
Initializing the OneDrive API ...
Configuring Global Azure AD Endpoints
Opening the item database ...
All operations will be performed in: /mnt/OneDrive/
Application version: v2.4.8-4-g5349340
Account Type: personal
Default Drive ID: 66d53be8a5056eca
Default Root ID: 66D53BE8A5056ECA!101
Remaining Free Space: 5368287434
Fetching details for OneDrive Root
OneDrive Root exists in the database
Initializing the Synchronization Engine ...
Syncing changes from OneDrive ...
Applying changes of Path ID: 66D53BE8A5056ECA!101
Updated Remaining Free Space: 5368287434
Uploading differences of /mnt/OneDrive
Processing .
The directory has not changed
Processing random_files
The directory has not changed
Processing random_images
The directory has not changed
Processing random_videos
The directory has not changed
Processing Dropbox
The directory has not changed
Processing Music
The directory has not changed
Processing Music/audio003.mp3
The file has not changed
Processing Images
The directory has not changed
Processing Images/image003.jpg
The file has not changed
Processing Documents
The directory has not changed
Processing Documents/Uni
The directory has not changed
Processing Documents/Uni/01
The directory has not changed
Processing Documents/Uni/01/asdfasdf.txt
The file last modified time has changed
Retry sync count: 1: Cannot open file `Documents/Uni/01/asdfasdf.txt' in mode `rb' (Permission denied)
Syncing changes from OneDrive ...
Applying changes of Path ID: 66D53BE8A5056ECA!101
Updated Remaining Free Space: 5368287434
Uploading differences of /mnt/OneDrive
Processing .
The directory has not changed
Processing random_files
The directory has not changed
Processing random_images
The directory has not changed
Processing random_videos
The directory has not changed
Processing Dropbox
The directory has not changed
Processing Music
The directory has not changed
Processing Music/audio003.mp3
The file has not changed
Processing Images
The directory has not changed
Processing Images/image003.jpg
The file has not changed
Processing Documents
The directory has not changed
Processing Documents/Uni
The directory has not changed
Processing Documents/Uni/01
The directory has not changed
Processing Documents/Uni/01/asdfasdf.txt
The file last modified time has changed
Retry sync count: 2: Cannot open file `Documents/Uni/01/asdfasdf.txt' in mode `rb' (Permission denied)
Syncing changes from OneDrive ...
Applying changes of Path ID: 66D53BE8A5056ECA!101
Updated Remaining Free Space: 5368287434
Uploading differences of /mnt/OneDrive
Processing .
The directory has not changed
Processing random_files
The directory has not changed
Processing random_images
The directory has not changed
Processing random_videos
The directory has not changed
Processing Dropbox
The directory has not changed
Processing Music
The directory has not changed
Processing Music/audio003.mp3
The file has not changed
Processing Images
The directory has not changed
Processing Images/image003.jpg
The file has not changed
Processing Documents
The directory has not changed
Processing Documents/Uni
The directory has not changed
Processing Documents/Uni/01
The directory has not changed
Processing Documents/Uni/01/asdfasdf.txt
The file last modified time has changed
Giving up on sync after three attempts: Cannot open file `Documents/Uni/01/asdfasdf.txt' in mode `rb' (Permission denied)
std.exception.ErrnoException@std/stdio.d(429): Cannot open file `Documents/Uni/01/asdfasdf.txt' in mode `rb' (Permission denied)
----------------
??:? @safe void std.exception.bailOut!(std.exception.ErrnoException).bailOut(immutable(char)[], ulong, scope const(char)[]) [0x5637a3f84417]
??:? @safe shared(core.stdc.stdio._IO_FILE)* std.exception.enforce!(std.exception.ErrnoException).enforce!(shared(core.stdc.stdio._IO_FILE)*).enforce(shared(core.stdc.stdio._IO_FILE)*, lazy const(char)[], immutable(char)[], ulong) [0x5637a40bbf9d]
??:? ref @safe std.stdio.File std.stdio.File.__ctor(immutable(char)[], scope const(char)[]) [0x5637a407a260]
??:? immutable(char)[] util.computeSha1Hash(immutable(char)[]) [0x5637a404f3ab]
??:? bool sync.testFileHash(const(immutable(char)[]), ref const(itemdb.Item)) [0x5637a4033d4a]
??:? void sync.SyncEngine.uploadFileDifferences(ref const(itemdb.Item), const(immutable(char)[])) [0x5637a4040abd]
??:? void sync.SyncEngine.uploadDifferences(ref const(itemdb.Item)) [0x5637a4040183]
??:? void sync.SyncEngine.uploadDirDifferences(ref const(itemdb.Item), const(immutable(char)[])) [0x5637a404031a]
??:? void sync.SyncEngine.uploadDifferences(ref const(itemdb.Item)) [0x5637a404016e]
??:? void sync.SyncEngine.uploadDirDifferences(ref const(itemdb.Item), const(immutable(char)[])) [0x5637a404031a]
??:? void sync.SyncEngine.uploadDifferences(ref const(itemdb.Item)) [0x5637a404016e]
??:? void sync.SyncEngine.uploadDirDifferences(ref const(itemdb.Item), const(immutable(char)[])) [0x5637a404031a]
??:? void sync.SyncEngine.uploadDifferences(ref const(itemdb.Item)) [0x5637a404016e]
??:? void sync.SyncEngine.uploadDirDifferences(ref const(itemdb.Item), const(immutable(char)[])) [0x5637a404031a]
??:? void sync.SyncEngine.uploadDifferences(ref const(itemdb.Item)) [0x5637a404016e]
??:? void sync.SyncEngine.scanForDifferences(const(immutable(char)[])) [0x5637a403eef1]
??:? void main.performSync(sync.SyncEngine, immutable(char)[], bool, bool, bool, long, bool, bool, bool, bool, monitor.Monitor) [0x5637a4024571]
??:? _Dmain [0x5637a4022d58]
std.net.curl.CurlException@std/net/curl.d(4402): A libcurl function was given a bad argument on handle null
----------------
??:? pure @safe void std.exception.bailOut!(std.net.curl.CurlException).bailOut(immutable(char)[], ulong, scope const(char)[]) [0x5637a40bc16e]
??:? pure @safe bool std.exception.enforce!(std.net.curl.CurlException).enforce!(bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0x5637a40bc0df]
??:? void std.net.curl.Curl._check(int) [0x5637a408b9db]
??:? void std.net.curl.Curl.clear(etc.c.curl.CurlOption) [0x5637a408bd86]
??:? void std.net.curl.HTTP.clearRequestHeaders() [0x5637a408aabb]
??:? void onedrive.OneDriveApi.shutdown() [0x5637a4028488]
??:? _Dmain [0x5637a4023a4b]

With PR

Using 'user' Config Dir: /home/alex/.config/onedrive
Using 'system' Config Dir: /etc/onedrive
Configuration file successfully loaded
Initializing the OneDrive API ...
Configuring Global Azure AD Endpoints
Opening the item database ...
All operations will be performed in: /mnt/OneDrive/
Application version: v2.4.8-8-gfcbf79f
Account Type: personal
Default Drive ID: 66d53be8a5056eca
Default Root ID: 66D53BE8A5056ECA!101
Remaining Free Space: 5368287434
Fetching details for OneDrive Root
OneDrive Root exists in the database
Initializing the Synchronization Engine ...
Syncing changes from OneDrive ...
Applying changes of Path ID: 66D53BE8A5056ECA!101
Updated Remaining Free Space: 5368287434
Uploading differences of /mnt/OneDrive
Processing .
The directory has not changed
Processing random_files
The directory has not changed
Processing random_images
The directory has not changed
Processing random_videos
The directory has not changed
Processing Dropbox
The directory has not changed
Processing Music
The directory has not changed
Processing Music/audio003.mp3
The file has not changed
Processing Images
The directory has not changed
Processing Images/image003.jpg
The file has not changed
Processing Documents
The directory has not changed
Processing Documents/Uni
The directory has not changed
Processing Documents/Uni/01
The directory has not changed
Processing Documents/Uni/01/asdfasdf.txt

ERROR: The local file system returned an error with the following message:
  Error Message:    Documents/Uni/01/asdfasdf.txt: Permission denied
  Calling Function: readLocalFile()

Skipping processing this file as it cannot be read (file permissions or file corruption): Documents/Uni/01/asdfasdf.txt
Processing Documents/Uni/02
The directory has not changed
Processing Documents/Uni/02/qwerqwer.txt
The file has not changed
Processing Documents/Uni/03
The directory has not changed
Processing Documents/Uni/03/zxcvzxcvzxcv.txt
The file has not changed
Processing Documents/Uni/04
The directory has not changed
Processing Documents/Uni/04/fghjfghjfghj.txt
The file has not changed
Processing Documents/Uni/05
The directory has not changed
Processing Documents/Uni/05/dfghdfghdfgh.txt
The file has not changed
Processing Documents/Music
The directory has not changed
Processing Documents/Music/audio001.mp3
The file has not changed
Processing Documents/Images
The directory has not changed
Processing Documents/Images/image001.jpg
The file has not changed
Processing Documents/SpeedTest
The directory has not changed
Uploading new items of /mnt/OneDrive
Skipping item - has disappeared: ./Documents/SpeedTest/Bandwidth measurement_ Speedtest.net.xlsx
Skipping item - has disappeared: ./Documents/SpeedTest/automated_speedtest.log
Skipping item - has disappeared: ./Documents/SpeedTest/Bandwidth measurement_ Speedtest.net.csv

ERROR: The local file system returned an error with the following message:
  Error Message:    ./Documents/Uni/01/asdfasdf-mint-20-read-only-2.txt: Permission denied
  Calling Function: readLocalFile()

Skipping uploading this file as it cannot be read (file permissions or file corruption): ./Documents/Uni/01/asdfasdf-mint-20-read-only-2.txt

ERROR: The local file system returned an error with the following message:
  Error Message:    ./Documents/Uni/01/asdfasdf-mint-20-read-only-3.txt: Permission denied
  Calling Function: readLocalFile()

Skipping uploading this file as it cannot be read (file permissions or file corruption): ./Documents/Uni/01/asdfasdf-mint-20-read-only-3.txt

ERROR: The local file system returned an error with the following message:
  Error Message:    ./Documents/Uni/01/asdfasdf-mint-20-read-only.txt: Permission denied
  Calling Function: readLocalFile()

Skipping uploading this file as it cannot be read (file permissions or file corruption): ./Documents/Uni/01/asdfasdf-mint-20-read-only.txt
Applying changes of Path ID: 66D53BE8A5056ECA!101
Updated Remaining Free Space: 5368287434

@abraunegg abraunegg requested a review from norbusan December 10, 2020 22:59
@abraunegg abraunegg added this to the v2.4.9 milestone Dec 10, 2020
@abraunegg abraunegg merged commit 9b44bb1 into master Dec 11, 2020
@abraunegg abraunegg deleted the fix-issue-1178 branch December 13, 2020 22:02
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators May 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception when file is not readable due to local file permissions on external mount point
2 participants