Commit graph

221 commits

Author SHA1 Message Date
abraunegg 2827467296 Resolve std.file.FileException when checking logfile path
* Resolve std.file.FileException@std/file.d(2954): /var/log/onedrive/: Permission denied when there is no permission to create the directory on application startup
2018-05-16 19:19:43 +10:00
Matthias C. M. Troffaes c863d2c3c9 Fix config folder. 2018-05-16 09:11:50 +01:00
abraunegg 0b1ca6dbfd Fix incorrect id tag
* Fix incorrect id tage when checking database if item exists
2018-05-15 07:15:54 +10:00
abraunegg 8b0e9513e3 Resolve another itemdb.d(307): Assertion
* Clean up --single-directory logging as we should not be spilling out the actual item details
* Fix some spelling errors
* Fix another core.exception.AssertError@src/itemdb.d(307): Assertion failure when attempting to compute the path
* Fix logging when items are being filtered out as non relevant
* Add upload validation that file uploaded equals the size of the file locally as this is a contributing factor to 412 errors
2018-05-15 06:59:17 +10:00
abraunegg 9520fe7716 Resolve itemdb.d(295): Assertion failure
* Resolve core.exception.AssertError@src/itemdb.d(295): Assertion failure when performing a --single-directory sync
2018-05-09 16:39:23 +10:00
abraunegg 41976ed216 Update long path handling
* Update long path handling to account for differences between OneDrive Personal and OneDrive Business Accounts
* Update logging to be cleaner on fragment uploads
2018-05-09 06:47:03 +10:00
abraunegg accb62bdeb Update logging of 500 & 504 errors
* Update logging of 500 & 504 errors. For 504 errors this was 'breaking the formatting of the log line. For 500 errors - this needs to be logged regardless of verbosity.
2018-05-07 05:37:47 +10:00
abraunegg 0c4def83f8 Resolve 500 & 504 HTTP Status Codes
* When completing some operations on OneDrive, a 504 error can be returned when Microsoft Graph times out when communicating with internal resources. Rather than failing, handle the 504 and retry the request.
* When performing numerous changes via OneDrive online, Microsoft Graph has an issue in interpreting the the response, thus generates a 500 internal server error. As this is something we cannot fix, handle the 500 error by gracefully exiting.
2018-05-05 17:00:50 +10:00
abraunegg 4e0c3a4cf0 Integrate #346 for sqlite performance enhancement
* Update database journal mode to WAL as per
https://www.sqlite.org/wal.html
2018-05-03 16:38:40 +10:00
abraunegg 0b5dc66507 Rework OneDrive generating a 412 'Precondition Failed' Error
* Rework the 412 fix so that the OneDrive client gracefully handles the
error & retries the metadata update without the eTag/cTag causing the
issue.
* Fix the double logging to console of 'upload' and 'download' items
2018-05-03 16:21:53 +10:00
abraunegg 90dec8d6f1 Resolve build deprecation warning
* Resolve build warning: Deprecation: `std.net.curl.dur` is not visible
from module by adding std.datetime & reordering dependancy import order
2018-04-30 19:41:54 +10:00
abraunegg ccd4dfbaf7 Resolve #341 '--single-directory' edge case
* Resolve where '--single-directory' is used to sync a single directory,
but a file / folder is 'moved' on OneDrive to outside the scope of the
focus of the '--single-directory' path. Before this change, the file
would remain in the local path (original location) whilst it would
reside in the new OneDrive path. This patch looks for this mis match and
deletes the local file / folder to reflect it is no longer in the same
OneDrive path.
2018-04-29 12:39:27 +10:00
abraunegg 6fe06d03ac Resolve 'Directory not empty' issues on bulk deletes
* In some cases OneDrive does not send all delete changes or changes are
out of order. When deleting local files, this can lead to a 'Directory
not empty' error. This change adds to check for any remaining children
of a directory that is to be deleted and delete them before
2018-04-26 09:45:18 +10:00
abraunegg 65a1181fcf Resolve std.exception.ErrnoException when user not part of users group
* Resolve: std.exception.ErrnoException@std/stdio.d(423): Cannot open
file `/var/log/onedrive/xxxxx.onedrive.log' in mode `a' (Permission
denied). This issue occurs if the user running 'onedrive' is not part of
the standard 'users' group (GID 100)
2018-04-25 12:11:34 +10:00
abraunegg bc15d7f77f Display informative message when not using --synchronize
* Prior to all the changes in #314, the client would sync regardless of
options. #314 introduced a flag that must be included if you want to
sync, however there was no feedback if '--synchronize' was not included
and the sync was not occuring. This patch provides that notification &
feedback.
2018-04-24 12:14:36 +10:00
abraunegg 034eccfaec Resolve #132 - Couldn't resolve host name on handle
* By default the DNS timeout on HTTP.method is too short. If DNS
resolution takes too long, a resolution error is thrown. Increase DNS
timeout to 5 seconds.
* Cleanup unittest - double declaration
2018-04-24 12:10:27 +10:00
abraunegg dff245d29b Resolve 'view.delta can only be called on the root'
* Resolve the error 'view.delta can only be called on the root' when
using OneDrive Business Account & --single-directory switch
* Change checkDatabaseForOneDriveRoot so that it is performed at init()
and not needed to be called a number of other times throughout the code
- leads to less HTTPS calls being made
* Cleanup comments that are no longer relevant due to
checkDatabaseForOneDriveRoot being run at init()
2018-04-23 10:58:47 +10:00
abraunegg 63f991a64e Reduce HTTPS calls for rootId & driveId by using init() set values
* Rather than make repeated HTTPS calls for the OneDrive rootId &
driveId, reuse the rootId & driveId as set via init() where possible
2018-04-21 16:30:35 +10:00
abraunegg 7a394a065f Resolve issue #73 - OneDrive Error 507 Insufficient Storage Exception
* Resolve https://github.com/skilion/onedrive/issues/73 by by tracking
the change in available free disk space when uploading a new file to
OneDrive
2018-04-21 14:54:50 +10:00
abraunegg 82ef982240 Configure at sync.init() global variables for driveId, rootId, accountType & space available
* Configure at sync.init() global variables for driveId, rootId,
accountType & space available
2018-04-21 14:32:39 +10:00
abraunegg 134c14e459 Resolve 'Key not found: lastModifiedDateTime' (OneDrive API change)
* Original patch (77c0cdbe24) whilst it
resolved the issue of a OneDrive API change, when a file was deleted on
OneDrive, it was not actually deleted on the local file system. This
patch re-implements the fix for 'Key not found: lastModifiedDateTime' by
taking into account the deleted state of the item and correctly removes
the local file that is now in the deleted state.
2018-04-21 14:03:02 +10:00
abraunegg 751d790631 Revert "Resolve 'Key not found: lastModifiedDateTime'"
This reverts commit 77c0cdbe24.
2018-04-21 07:32:31 +10:00
abraunegg 076b180e63 Revert "Manually revert lastModifiedDateTime"
This reverts commit 4a8456fa96.
2018-04-21 07:32:18 +10:00
abraunegg 4a8456fa96 Manually revert lastModifiedDateTime
* Manually revert lastModifiedDateTime
2018-04-21 07:24:19 +10:00
abraunegg 8a059dc0e1 Revert "Switch to using list_children for an item id's children"
This reverts commit fedaedacd7.
2018-04-21 07:19:04 +10:00
abraunegg 3d224d0595 Revert "Resolve issue #73 - 507 Insufficiente Storage Exception"
This reverts commit 648c1ef094.
2018-04-21 07:19:00 +10:00
abraunegg 894bdcde08 Revert "Fix itemdb.d assertion"
This reverts commit 66d00c5ec9.
2018-04-21 07:18:53 +10:00
abraunegg 095aa64cd6 Revert "Revert 77c0cdbe24 temporarily"
This reverts commit be03fa48df.
2018-04-21 07:18:46 +10:00
abraunegg be03fa48df Revert 77c0cdbe24 temporarily
* The fix in 77c0cdbe24 whilst resolves
'Key not found: lastModifiedDateTime' introduces a bug where files
deleted by onedrive, are not deleted locally. Reverting the change to
implement a fuller fix for 'Key not found: lastModifiedDateTime'.
2018-04-21 07:09:18 +10:00
abraunegg 66d00c5ec9 Fix itemdb.d assertion
* Fix core.exception.AssertError@src/itemdb.d(293): Assertion failure
introduced after onedrive.viewChildrenById(driveId, id) change
(fedaedacd7)
2018-04-20 18:41:49 +10:00
abraunegg 648c1ef094 Resolve issue #73 - 507 Insufficiente Storage Exception
* Resove https://github.com/skilion/onedrive/issues/73 by implementing a
check, initialised on init() to track the space used by uploads vs space
available
2018-04-19 16:14:42 +10:00
abraunegg fedaedacd7 Switch to using list_children for an item id's children
* Change how onedrive get's the children from a particular item id.
Previously view.delta was used to return the children, however
view.delta is not implemented on children when using OneDrive Business
accounts. By using list_children, we can get the children from any id
correctly when using either a 'personal' or 'business' account
2018-04-19 14:31:35 +10:00
abraunegg 77c0cdbe24 Resolve 'Key not found: lastModifiedDateTime'
* Fix 'Key not found: lastModifiedDateTime'
* Handling of Tombstoned items in the database
* Add for debugging purposes the rootID, driveID and Account Type
* Code cleanup - remove old commented out debugging items that are not
needed
2018-04-18 06:28:08 +10:00
abraunegg 835806f0eb Update "hidden" directory & skip_file handling
* Partial rollback of 570d42269e to
original logic behind isNameExcluded()
* Removed .* from default skip_file configuration
2018-04-16 21:39:45 +10:00
abraunegg 5cb92c01b9 Expand HTTPS debug to include GET JSON responses
* Change debug flag from --debug-http to --debug-https as OneDrive only
uses HTTPS, not HTTP
* Expand --debug-https to print the JSON responses to GET operations.
This is to assist with debugging #334 where a change in the MS API
(https://github.com/OneDrive/onedrive-api-docs/issues/834) no longer
sends 'lastModifiedDateTime' with responses to some GET's. This issue
seems to manefest itself with OneDrive Business accounts currently.
2018-04-15 20:02:39 +10:00
abraunegg 0febd67bd3 Add Microsoft naming conventions and namespace validation for items that will be uploaded
* Add Pull #104 (@JunpeiAnzai) to ensure that uploaded files conform to
Windows naming conventions and namespaces. Refer to
https://msdn.microsoft.com/en-us/library/aa365247 for further details
regarding Windows naming conventions and namespaces.
2018-04-13 11:20:38 +10:00
abraunegg 21f4d8e858 Add init.d service file & modify how configDirName is set
* Add init.d service file & helper script to start service
* Change how configDirName is set as XDG_CONFIG_HOME does not exist on
systems where X11 is not present. When using init scripts and using
XDG_CONFIG_HOME, ~ is not expanded thus existing config cannot be found.
Using ~ in --confdir also does not work when running under init.d
2018-04-13 09:33:16 +10:00
abraunegg 091e675d85 Update README.md based on current changes made
* Update readme
* Tweak logging output based on sync options selected
2018-04-12 10:18:18 +10:00
abraunegg 7eb11f0b44 Log why we are skipping a large file for upload
Log the reason why a file is not being uploaded (missed this in fec7654)
2018-04-12 08:44:52 +10:00
abraunegg fec7654118 Resolve Issues #121, #294, #329
Resolve onedrive crash when uploading files that exceed the allowed
OneDrive individual file limit
2018-04-12 07:31:42 +10:00
abraunegg 570d42269e Fix onedrive not syncing "hidden" directories
* Fix the handling of hidden filenames & directories (.hello, .git etc)
so that these are uploaded / downloaded without issue.
* Add verbose logging for uploaded files as to why they were skipped
2018-04-11 13:02:06 +10:00
abraunegg 5e0e763317 Change logging of upload, download and deletion activities
Prior to this change logging of upload, download and deletion activities
were only written to the log file when using the --verbose flag, however
they would be written to console / syslog. This corrects that behaviour.
2018-04-10 20:03:28 +10:00
abraunegg f1aa190a91 Add uploadOnly flag and add username to logfile name
* Add specific uploadOnly flag so that the onedrive client only uploads
data from the local directory and does not download changes from
OneDrive
* Change the logfile name to include the username running the onedrive
client
2018-04-07 17:06:57 +10:00
abraunegg 8463e60acc Update onedrive.d to remove '&'
Change '&error' to 'error' on line 37 of onedrive.d

Issue uncovered where prior code with '&' would compile without issue on
DMD reference compiler v2.078.3 and below, but using '2.079.0' this
would throw an error if '&' was present.

The original patch added the '&' to get the code to compile, this simple
reverts this change.

Note: For future reference compile this code with DMD v2.079.0 or later.
2018-03-30 08:14:00 +11:00
abraunegg dd73ae3c4b OneDrive Client Changes
* Fix 4xx errors including (412 pre-condition)
* Add Logging - log to a file (/var/log/onedrive/onedrive.log)
* Add http(s) debugging as a flag
* Add dont sync when just blindly running the application
* Add individual folder sync - ie ~/OneDrive/blah/ vs. syncing
everything in ~/OneDrive/
* Add sync from local directory first rather than download first then
upload
* Add upload long path check (430 character limitation)
2018-03-14 15:43:40 +11:00
skilion c231b13ad4 Disabled buffering on stdout 2018-02-18 18:24:46 +01:00
skilion 008a5756b3 Fix crash when the delta link is expired 2018-02-18 18:02:38 +01:00
skilion d9a5d1b3b9 fix regex for parsing authentication uri 2018-01-20 21:13:01 +01:00
Mikael Göransson a1e326f9b4 invalid_grant, error 70000
when trying to redeem an code, this error always occured, no matter
which parts of the response uri/url that was used.

the old regexp for parsing the code contained 3 groups, where as the
actual code always was the last group, and the second group was either ?
or &, and the first group would've been everything up until "code=".

changed from a matching group to character class so there would only be
two matching groups, so calling popFront() would actually leave the
authorization code in the front.
2018-01-20 20:51:33 +01:00
skilion 867c8ed26c improved regex 2018-01-19 18:56:14 +01:00