From 7cf73a21f213d6cfae6ae665cfb926f91dfb1239 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Fri, 28 Jun 2019 17:38:38 +1000 Subject: [PATCH] remove try block * remove try block and trap for explicit entry earlier --- src/sync.d | 8 ++++++-- src/upload.d | 9 +++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/sync.d b/src/sync.d index 4282cb5b9..311230852 100644 --- a/src/sync.d +++ b/src/sync.d @@ -2058,7 +2058,6 @@ final class SyncEngine writeln(""); try { response = session.upload(path, parent.driveId, parent.id, baseName(path)); - writeln(" done."); } catch (OneDriveException e) { // error uploading file log.vlog("Upload failed with OneDriveException: ", e.msg); @@ -2067,17 +2066,22 @@ final class SyncEngine log.vlog("Upload failed with File Exception: ", e.msg); return; } + writeln(" done."); } } else { // OneDrive Business Account - always use a session to upload writeln(""); try { response = session.upload(path, parent.driveId, parent.id, baseName(path)); - writeln(" done."); } catch (OneDriveException e) { // error uploading file + log.vlog("Upload failed with OneDriveException: ", e.msg); + return; + } catch (FileException e) { + log.vlog("Upload failed with File Exception: ", e.msg); return; } + writeln(" done."); } } diff --git a/src/upload.d b/src/upload.d index 2c9e26144..d01873405 100644 --- a/src/upload.d +++ b/src/upload.d @@ -39,13 +39,14 @@ struct UploadSession ]) ]; - try { - // Try to create the upload session for this file - session = onedrive.createUploadSession(parentDriveId, parentId, filename, eTag, fileSystemInfo); + // Try to create the upload session for this file + session = onedrive.createUploadSession(parentDriveId, parentId, filename, eTag, fileSystemInfo); + + if ("uploadUrl" in session){ session["localPath"] = localPath; save(); return upload(); - } catch (OneDriveException e) { + } else { // there was an error log.vlog("Create file upload session failed ... skipping file upload"); // return upload() will return a JSONValue response, create an empty JSONValue response to return