mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-07 00:12:12 +02:00
* Catch a 412 response when moving files right after upload.
This commit is contained in:
parent
12947d160f
commit
df3fba1be0
21
src/sync.d
21
src/sync.d
|
@ -3200,10 +3200,25 @@ final class SyncEngine
|
||||||
"lastModifiedDateTime": mtime.toISOExtString()
|
"lastModifiedDateTime": mtime.toISOExtString()
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
auto res = onedrive.updateById(fromItem.driveId, fromItem.id, diff, fromItem.eTag);
|
|
||||||
// update itemdb
|
// Perform the move operation on OneDrive
|
||||||
|
JSONValue response;
|
||||||
|
try {
|
||||||
|
response = onedrive.updateById(fromItem.driveId, fromItem.id, diff, fromItem.eTag);
|
||||||
|
} catch (OneDriveException e) {
|
||||||
|
if (e.httpStatusCode == 412) {
|
||||||
|
// OneDrive threw a 412 error, most likely: ETag does not match current item's value
|
||||||
|
// Retry without eTag
|
||||||
|
log.vdebug("File Move Failed - OneDrive eTag / cTag match issue");
|
||||||
|
log.vlog("OneDrive returned a 'HTTP 412 - Precondition Failed' when attempting to move the file - gracefully handling error");
|
||||||
|
string nullTag = null;
|
||||||
|
// move the file but without the eTag
|
||||||
|
response = onedrive.updateById(fromItem.driveId, fromItem.id, diff, nullTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// save the move response from OneDrive in the database
|
||||||
// Is the response a valid JSON object - validation checking done in saveItem
|
// Is the response a valid JSON object - validation checking done in saveItem
|
||||||
saveItem(res);
|
saveItem(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue