Fix JSONValue is not an object crash when a 5xx error is returned when uploading files (#426)

* Fix JSONValue is not an object crash when a 5xx error is returned when uploading files
This commit is contained in:
abraunegg 2019-03-22 10:23:21 +11:00 committed by GitHub
parent 0dfc165534
commit de98fe8492
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1684,6 +1684,8 @@ final class SyncEngine
auto maxUploadFileSize = 16106127360; // 15GB
//auto maxUploadFileSize = 21474836480; // 20GB
auto thisFileSize = getSize(path);
// To avoid a 409 Conflict error - does the file actually exist on OneDrive already?
JSONValue fileDetailsFromOneDrive;
// Can we read the file - as a permissions issue or file corruption will cause a failure
// https://github.com/abraunegg/onedrive/issues/113
@ -1691,10 +1693,6 @@ final class SyncEngine
// able to read the file
if (thisFileSize <= maxUploadFileSize){
// Resolves: https://github.com/skilion/onedrive/issues/121, https://github.com/skilion/onedrive/issues/294, https://github.com/skilion/onedrive/issues/329
// To avoid a 409 Conflict error - does the file actually exist on OneDrive already?
JSONValue fileDetailsFromOneDrive;
// Does this 'file' already exist on OneDrive?
try {
// test if the local path exists on OneDrive
@ -1841,7 +1839,8 @@ final class SyncEngine
// even though some file systems (such as a POSIX-compliant file system) may consider them as different.
// Note that NTFS supports POSIX semantics for case sensitivity but this is not the default behavior.
if (fileDetailsFromOneDrive["name"].str == baseName(path)){
// Check that 'name' is in the JSON response (validates data) and that 'name' == the path we are looking for
if (("name" in fileDetailsFromOneDrive) && (fileDetailsFromOneDrive["name"].str == baseName(path))) {
// OneDrive 'name' matches local path name
log.vlog("Requested file to upload exists on OneDrive - local database is out of sync for this file: ", path);