Update enforce statement for parent id database query (Issue #912) (#913)

* Update database enforce check with conditional check on parent drive ID. If the parent is a shared folder, the parent ID will never be in the database as we are never provided that parent ID.
This commit is contained in:
abraunegg 2020-05-10 05:42:46 +10:00 committed by GitHub
parent 503f360c87
commit 2529b99265
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2990,11 +2990,17 @@ final class SyncEngine
// Perform the database lookup - is the parent in the database?
if (!itemdb.selectByPath(dirName(path), parent.driveId, parent)) {
// parent is not in the database
log.vdebug("Parent path is not in the database - need to add it");
log.vdebug("Parent path is not in the database - need to add it: ", dirName(path));
uploadCreateDir(dirName(path));
}
// still enforce check of parent path. if the above was triggered, the below will generate a sync retry and will now be sucessful
enforce(itemdb.selectByPath(dirName(path), parent.driveId, parent), "The parent item id is not in the database");
// Is the parent a 'folder' from another user? ie - is this a 'shared folder' that has been shared with us?
if (defaultDriveId == parent.driveId){
// enforce check of parent path. if the above was triggered, the below will generate a sync retry and will now be sucessful
enforce(itemdb.selectByPath(dirName(path), parent.driveId, parent), "The parent item id is not in the database");
} else {
log.vdebug("Parent drive ID is not our drive ID - parent most likely a shared folder");
}
JSONValue driveItem = [
"name": JSONValue(baseName(path)),