-
-
Notifications
You must be signed in to change notification settings - Fork 868
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
Check if localModifiedTime >= item.mtime: avoid re-upload #1131
Conversation
… equal modified time
@mp1994 |
src/sync.d
Outdated
@@ -131,11 +131,12 @@ private Item makeItem(const ref JSONValue driveItem) | |||
// https://github.com/abraunegg/onedrive/issues/11 | |||
if (isItemRemote(driveItem)) { | |||
item.mtime = SysTime.fromISOExtString(driveItem["remoteItem"]["fileSystemInfo"]["lastModifiedDateTime"].str); | |||
log.vdebug("Remote item time: ", item.mtime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remote item here is not 'local' or 'remote', but a OneDrive object that resides on another drive id which is not the account default - typically this is onedrive shared folder
src/sync.d
Outdated
@@ -2146,6 +2147,7 @@ final class SyncEngine | |||
if (cached && item.eTag != oldItem.eTag) { | |||
// Is the item in the local database | |||
if (itemdb.idInLocalDatabase(item.driveId, item.id)){ | |||
log.vdebug(">> Item in local database.\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will need to be cleaned up
src/sync.d
Outdated
//log.vdebug("localModifiedTime (local file): ", localModifiedTime); | ||
//log.vdebug("item.mtime (OneDrive item): ", item.mtime); | ||
log.vlog("local file modified time: ", localModifiedTime); | ||
log.vlog("OneDrive database item time (item.mtime): ", item.mtime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item.mtime is not the database item - but the item provided by OneDrive via the API
* Update PR
@mp1994 |
@abraunegg thank you for working on this, I have tested the PR with the following output
Output of the log relative to the modified file:
It worked as intended, the local file is kept without |
* tweak debug output messaging
@mp1994 |
@abraunegg that's great, thank you! |
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. |
In file
sync.d
, in functionprivate void applyDifference(JSONValue driveItem, string driveId, bool isRoot)
, check iflocalModifiedTime
is greater or equal to the item modified time (item.mtime
). This avoid the re-upload in case another process has modified the file in the local disk and that change is already synchronized with remote.This happens when local file time = remote file time > local database time
Example (that requires no fix): remote file time > local file time = local database time, if the file is modified online. The sync correctly updates the local file with no issues.
Example (that requires this fix): local file is changed using a Windows Virtual Machine with OneDrive, that updates also the remote file. When
onedrive --synchronize
runs on linux, the local file time is equal to the remote time, and both are greater than the local database time. This fix avoids thesafeRename
while updating the local database entry.This may be very specific to my configuration, but it should be completely transparent to "conventional" configurations. Thus, I hope this PR will be merged!