From 9520fe771687e1f8ee13f8ebe97cd88bba8195d7 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Wed, 9 May 2018 16:39:23 +1000 Subject: [PATCH] Resolve itemdb.d(295): Assertion failure * Resolve core.exception.AssertError@src/itemdb.d(295): Assertion failure when performing a --single-directory sync --- src/itemdb.d | 12 ++++++++++++ src/sync.d | 20 ++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/itemdb.d b/src/itemdb.d index c8eeedf2..5a2cd616 100644 --- a/src/itemdb.d +++ b/src/itemdb.d @@ -141,6 +141,18 @@ final class ItemDatabase return false; } + // returns if an item id is in the database + bool idInLocalDatabase(const(string) driveId, const(string)id) + { + selectItemByIdStmt.bind(1, driveId); + selectItemByIdStmt.bind(2, id); + auto r = selectItemByIdStmt.exec(); + if (!r.empty) { + return true; + } + return false; + } + // returns the item with the given path // the path is relative to the sync directory ex: "./Music/Turbo Killer.mp3" bool selectByPath(const(char)[] path, string rootDriveId, out Item item) diff --git a/src/sync.d b/src/sync.d index 991b5824..3505fde4 100644 --- a/src/sync.d +++ b/src/sync.d @@ -389,15 +389,19 @@ final class SyncEngine } // Yes .. ID is still on OneDrive but elsewhere .... #341 edge case handling // What is the original local path for this ID in the database? Does it match 'syncFolderName' - string originalLocalPath = itemdb.computePath(driveId, item["id"].str); - - if (canFind(originalLocalPath, syncFolderName)){ - // This 'change' relates to an item that WAS in 'syncFolderName' but is now - // stored elsewhere on OneDrive - outside the path we are syncing from - // Remove this item locally as it's local path is now obsolete - idsToDelete ~= [driveId, item["id"].str]; + if (itemdb.idInLocalDatabase(driveId, item["id"].str)){ + // item is in the database + string originalLocalPath = itemdb.computePath(driveId, item["id"].str); + if (canFind(originalLocalPath, syncFolderName)){ + // This 'change' relates to an item that WAS in 'syncFolderName' but is now + // stored elsewhere on OneDrive - outside the path we are syncing from + // Remove this item locally as it's local path is now obsolete + idsToDelete ~= [driveId, item["id"].str]; + } + } else { + log.vlog("Remote Change Discarded: ", item); } - } + } } }