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