From 540c2369f35d7caf8d28b45ed8a748b5924d2365 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Mon, 22 Nov 2021 17:42:29 +1100 Subject: [PATCH] Fix error 'Key not found: remaining' with Business Shared Folders (#1713) * Fix an API regression where the 'remaining' value for some API responses is no longer present in the 'quota' JSON response --- src/sync.d | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/sync.d b/src/sync.d index a324f02e..95e293a9 100644 --- a/src/sync.d +++ b/src/sync.d @@ -387,7 +387,15 @@ final class SyncEngine accountType = oneDriveDetails["driveType"].str; defaultDriveId = oneDriveDetails["id"].str; defaultRootId = oneDriveRootDetails["id"].str; - remainingFreeSpace = oneDriveDetails["quota"]["remaining"].integer; + + // get the remaining size from OneDrive API + if ("remaining" in oneDriveDetails["quota"]){ + // use the value provided + remainingFreeSpace = oneDriveDetails["quota"]["remaining"].integer; + } else { + // set at zero + remainingFreeSpace = 0; + } // Make sure that defaultDriveId is in our driveIDs array to use when checking if item is in database // Keep the driveIDsArray with unique entries only @@ -1225,9 +1233,12 @@ final class SyncEngine } } else { // quota details returned, but for a drive id that is not ours - if (currentDriveQuota["quota"]["remaining"].integer <= 0) { - // value returned is 0 or less than 0 - log.vlog("OneDrive quota information is set at zero, as this is not our drive id, ignoring"); + if ("remaining" in currentDriveQuota["quota"]){ + // remaining is in the quota JSON response + if (currentDriveQuota["quota"]["remaining"].integer <= 0) { + // value returned is 0 or less than 0 + log.vlog("OneDrive quota information is set at zero, as this is not our drive id, ignoring"); + } } } } else {