Skip to content

Commit

Permalink
Fix 'Skipping uploading this new file as parent path is not in the da…
Browse files Browse the repository at this point in the history
…tabase' when uploading to a Personal Shared Folder (#1009)

* Fix 'Skipping uploading this new file as parent path is not in the database' when uploading to a Personal Shared Folder
* When syncing OneDrive Personal Shared Folders, add the driveId to the driveIdArray
* Rename function to be more representative of what function does
  • Loading branch information
abraunegg authored Aug 6, 2020
1 parent 2fe0574 commit 786446f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/itemdb.d
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ final class ItemDatabase
}

// same as selectByPath() but it does not traverse remote folders
bool selectByPathWithRemote(const(char)[] path, string rootDriveId, out Item item)
bool selectByPathWithoutRemote(const(char)[] path, string rootDriveId, out Item item)
{
Item currItem = { driveId: rootDriveId };

Expand Down
17 changes: 11 additions & 6 deletions src/sync.d
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,13 @@ final class SyncEngine
} else {
log.vlog("Syncing this OneDrive Personal Shared Folder: ", item.name);
}
// Check OneDrive Personal Folders
// Check this OneDrive Personal Shared Folders
applyDifferences(item.remoteDriveId, item.remoteId, performFullItemScan);
// Keep the driveIDsArray with unique entries only
if (!canFind(driveIDsArray, item.remoteDriveId)) {
// Add this OneDrive Personal Shared Folder driveId array
driveIDsArray ~= item.remoteDriveId;
}
}
}

Expand Down Expand Up @@ -2942,7 +2947,7 @@ final class SyncEngine
// we are in a --dry-run situation, directory appears to have deleted locally - this directory may never have existed as we never downloaded it ..
// Check if path does not exist in database
Item databaseItem;
if (!itemdb.selectByPathWithRemote(path, defaultDriveId, databaseItem)) {
if (!itemdb.selectByPathWithoutRemote(path, defaultDriveId, databaseItem)) {
// Path not found in database
log.vlog("The directory has been deleted locally");
if (noRemoteDelete) {
Expand Down Expand Up @@ -3617,7 +3622,7 @@ final class SyncEngine
foreach (driveId; driveIDsArray) {
// Query the database for this parent path using each driveId
Item dbResponse;
if(itemdb.selectByPathWithRemote(parentPath, driveId, dbResponse)){
if(itemdb.selectByPathWithoutRemote(parentPath, driveId, dbResponse)){
// parent path was found in the database
parent = dbResponse;
}
Expand Down Expand Up @@ -3821,7 +3826,7 @@ final class SyncEngine
foreach (driveId; driveIDsArray) {
// Query the database for this parent path using each driveId
Item dbResponse;
if(itemdb.selectByPathWithRemote(parentPath, driveId, dbResponse)){
if(itemdb.selectByPath(parentPath, driveId, dbResponse)){
// parent path was found in the database
parent = dbResponse;
parentPathFoundInDB = true;
Expand Down Expand Up @@ -4753,7 +4758,7 @@ final class SyncEngine
}
if (fromItem.parentId == null) {
// the item is a remote folder, need to do the operation on the parent
enforce(itemdb.selectByPathWithRemote(from, defaultDriveId, fromItem));
enforce(itemdb.selectByPathWithoutRemote(from, defaultDriveId, fromItem));
}
if (itemdb.selectByPath(to, defaultDriveId, toItem)) {
// the destination has been overwritten
Expand Down Expand Up @@ -4832,7 +4837,7 @@ final class SyncEngine
}
if (item.parentId == null) {
// the item is a remote folder, need to do the operation on the parent
enforce(itemdb.selectByPathWithRemote(path, defaultDriveId, item));
enforce(itemdb.selectByPathWithoutRemote(path, defaultDriveId, item));
}
try {
if (noRemoteDelete) {
Expand Down

0 comments on commit 786446f

Please sign in to comment.