From c74282879b0fdbb21d9da5bc8124a5a721c7bf54 Mon Sep 17 00:00:00 2001 From: skilion Date: Mon, 21 Sep 2015 17:23:12 +0200 Subject: [PATCH] fix Precondition Failed after upload --- src/sync.d | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/sync.d b/src/sync.d index f9566a93..6e093832 100644 --- a/src/sync.d +++ b/src/sync.d @@ -394,7 +394,10 @@ final class SyncEngine auto res = onedrive.simpleUpload(path, path, item.eTag); saveItem(res); id = res["id"].str; - eTag = res["eTag"].str; + /* use the cTag instead of the eTag because Onedrive changes the + * metadata of some type of files (ex. images) AFTER they have been + * uploaded */ + eTag = res["cTag"].str; } uploadLastModifiedTime(id, eTag, localModifiedTime.toUTC()); } else { @@ -449,9 +452,12 @@ final class SyncEngine JSONValue res = onedrive.simpleUpload(path, path); saveItem(res); string id = res["id"].str; - string eTag = res["eTag"].str; + string cTag = res["cTag"].str; SysTime mtime = timeLastModified(path).toUTC(); - uploadLastModifiedTime(id, eTag, mtime); + /* use the cTag instead of the eTag because Onedrive changes the + * metadata of some type of files (ex. images) AFTER they have been + * uploaded */ + uploadLastModifiedTime(id, cTag, mtime); } private void uploadDeleteItem(Item item, const(char)[] path)