diff --git a/src/main.d b/src/main.d index 02f72313..3584a022 100644 --- a/src/main.d +++ b/src/main.d @@ -1043,7 +1043,7 @@ int main(string[] args) log.vlog("Offline, cannot delete item!"); } catch(SyncException e) { if (e.msg == "The item to delete is not in the local database") { - log.vlog("Item cannot be deleted from OneDrive because not found in the local database"); + log.vlog("Item cannot be deleted from OneDrive because it was not found in the local database"); } else { log.logAndNotify("Cannot delete remote item: ", e.msg); } diff --git a/src/sync.d b/src/sync.d index c8d781cb..0569edf7 100644 --- a/src/sync.d +++ b/src/sync.d @@ -933,7 +933,17 @@ final class SyncEngine } Item item; - if (!itemdb.selectByPath(path, defaultDriveId, item)) { + // Need to check all driveid's we know about, not just the defaultDriveId + bool itemInDB = false; + foreach (searchDriveId; driveIDsArray) { + if (itemdb.selectByPath(path, searchDriveId, item)) { + // item was found in the DB + itemInDB = true; + break; + } + } + // Was the item found in the DB + if (!itemInDB) { // this is odd .. this directory is not in the local database - just go delete it log.vlog("The requested directory to delete was not found in the local database - pushing delete request direct to OneDrive"); uploadDeleteItem(item, path); @@ -5331,9 +5341,19 @@ final class SyncEngine void deleteByPath(const(string) path) { Item item; - if (!itemdb.selectByPath(path, defaultDriveId, item)) { + // Need to check all driveid's we know about, not just the defaultDriveId + bool itemInDB = false; + foreach (searchDriveId; driveIDsArray) { + if (itemdb.selectByPath(path, searchDriveId, item)) { + // item was found in the DB + itemInDB = true; + break; + } + } + if (!itemInDB) { throw new SyncException("The item to delete is not in the local database"); } + if (item.parentId == null) { // the item is a remote folder, need to do the operation on the parent enforce(itemdb.selectByPathWithoutRemote(path, defaultDriveId, item));