Resolve itemdb.d(295): Assertion failure

* Resolve core.exception.AssertError@src/itemdb.d(295): Assertion failure when performing a --single-directory sync
This commit is contained in:
abraunegg 2018-05-09 16:39:23 +10:00
parent 41976ed216
commit 9520fe7716
2 changed files with 24 additions and 8 deletions

View file

@ -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)

View file

@ -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);
}
}
}
}
}