Fix an unhandled Error 412 when uploading modified files to OneDrive Business Accounts (#1394)

* Update error 412 handling when uploading modified files to OneDrive Business Accounts
This commit is contained in:
abraunegg 2021-04-09 06:21:01 +10:00 committed by GitHub
parent 97a468e606
commit 615aa05b42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3425,7 +3425,7 @@ final class SyncEngine
// HTTP request returned status code 412 - ETag does not match current item's value
// Delete record from the local database - file will be uploaded as a new file
writeln("skipped.");
log.vdebug("Simple Upload Replace Failed - OneDrive eTag / cTag match issue");
log.vdebug("Simple Upload Replace Failed - OneDrive eTag / cTag match issue (Personal Account)");
log.vlog("OneDrive returned a 'HTTP 412 - Precondition Failed' - gracefully handling error. Will upload as new file.");
itemdb.deleteById(item.driveId, item.id);
uploadFailed = true;
@ -3468,7 +3468,7 @@ final class SyncEngine
// HTTP request returned status code 412 - ETag does not match current item's value
// Delete record from the local database - file will be uploaded as a new file
writeln("skipped.");
log.vdebug("Simple Upload Replace Failed - OneDrive eTag / cTag match issue");
log.vdebug("Session Upload Replace Failed - OneDrive eTag / cTag match issue (Personal Account)");
log.vlog("OneDrive returned a 'HTTP 412 - Precondition Failed' - gracefully handling error. Will upload as new file.");
itemdb.deleteById(item.driveId, item.id);
uploadFailed = true;
@ -3539,6 +3539,16 @@ final class SyncEngine
log.fileOnly(path, " is currently checked out or locked for editing by another user.");
uploadFailed = true;
return;
}
if (e.httpStatusCode == 412) {
// HTTP request returned status code 412 - ETag does not match current item's value
// Delete record from the local database - file will be uploaded as a new file
writeln("skipped.");
log.vdebug("Session Upload Replace Failed - OneDrive eTag / cTag match issue (Business Account)");
log.vlog("OneDrive returned a 'HTTP 412 - Precondition Failed' - gracefully handling error. Will upload as new file.");
itemdb.deleteById(item.driveId, item.id);
uploadFailed = true;
return;
} else {
// display what the error is
writeln("skipped.");
@ -3727,7 +3737,7 @@ final class SyncEngine
log.vlog("OneDrive returned a 'HTTP 401 - Unauthorized' - gracefully handling error");
uploadFailed = true;
return response;
}
}
// Resolve https://github.com/abraunegg/onedrive/issues/36
if ((e.httpStatusCode == 409) || (e.httpStatusCode == 423)) {
// The file is currently checked out or locked for editing by another user
@ -3738,6 +3748,16 @@ final class SyncEngine
log.fileOnly(path, " is currently checked out or locked for editing by another user.");
uploadFailed = true;
return response;
}
if (e.httpStatusCode == 412) {
// HTTP request returned status code 412 - ETag does not match current item's value
// Delete record from the local database - file will be uploaded as a new file
writeln("skipped.");
log.vdebug("Session Upload Replace Failed - OneDrive eTag / cTag match issue (Sharepoint Library)");
log.vlog("OneDrive returned a 'HTTP 412 - Precondition Failed' - gracefully handling error. Will upload as new file.");
itemdb.deleteById(item.driveId, item.id);
uploadFailed = true;
return response;
} else {
// display what the error is
writeln("skipped.");