From c617185c143ddc669889c4fae7117a196fe617c1 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Mon, 3 Jun 2019 10:43:16 +1000 Subject: [PATCH] Update missing cTag patch (Issue #512) (#515) * Update original patch to check for eTag in response to use, if not found set to empty value. * Add cTag response validation for all cTag response use 'in-case' the cTag response is dropped from other responses --- src/sync.d | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/sync.d b/src/sync.d index ac17aff3..5c1c2726 100644 --- a/src/sync.d +++ b/src/sync.d @@ -1535,8 +1535,14 @@ final class SyncEngine // use the cTag instead of the eTag because OneDrive may update the metadata of files AFTER they have been uploaded via simple upload eTag = response["cTag"].str; } else { - // cTag missing in response, use the original item.etag - eTag = item.eTag; + // Is there an eTag in the response? + if ("eTag" in response) { + // use the eTag from the response as there was no cTag + eTag = response["eTag"].str; + } else { + // no tag available - set to nothing + eTag = ""; + } } } else { // we are --dry-run - simulate the file upload @@ -2021,10 +2027,25 @@ final class SyncEngine if ((accountType == "personal") || (thisFileSize == 0)){ // Update the item's metadata on OneDrive string id = response["id"].str; - string cTag = response["cTag"].str; + string cTag; + + // Is there a valid cTag in the response? + if ("cTag" in response) { + // use the cTag instead of the eTag because OneDrive may update the metadata of files AFTER they have been uploaded + cTag = response["cTag"].str; + } else { + // Is there an eTag in the response? + if ("eTag" in response) { + // use the eTag from the response as there was no cTag + cTag = response["eTag"].str; + } else { + // no tag available - set to nothing + cTag = ""; + } + } + if (exists(path)) { SysTime mtime = timeLastModified(path).toUTC(); - // use the cTag instead of the eTag because OneDrive may update the metadata of files AFTER they have been uploaded uploadLastModifiedTime(parent.driveId, id, cTag, mtime); } else { // will be removed in different event! @@ -2092,9 +2113,24 @@ final class SyncEngine writeln(" done."); } string id = response["id"].str; - string cTag = response["cTag"].str; + string cTag; + + // Is there a valid cTag in the response? + if ("cTag" in response) { + // use the cTag instead of the eTag because Onedrive may update the metadata of files AFTER they have been uploaded + cTag = response["cTag"].str; + } else { + // Is there an eTag in the response? + if ("eTag" in response) { + // use the eTag from the response as there was no cTag + cTag = response["eTag"].str; + } else { + // no tag available - set to nothing + cTag = ""; + } + } + SysTime mtime = timeLastModified(path).toUTC(); - // use the cTag instead of the eTag because Onedrive may update the metadata of files AFTER they have been uploaded uploadLastModifiedTime(parent.driveId, id, cTag, mtime); } else { // OneDrive Business account modified file upload handling