Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Mar 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/sync.d
Original file line number Diff line number Diff line change
Expand Up @@ -1682,17 +1682,15 @@ 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
if (readLocalFile(path)){
// 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
Expand Down Expand Up @@ -1839,7 +1837,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);

Expand Down