Skip to content

Commit

Permalink
Properly handle a missing parent folder. (#188)
Browse files Browse the repository at this point in the history
During sync, gracefully handle the situation that an entity's parent
folder is missing.  This can happen temporarily while we are still
retrieving data, for instance.  Without this change, the sync will abort
and fail, even if the parent folder is actually there and would be added
in later.

Co-authored-by: Daniel Kraft <[email protected]>
Co-authored-by: Ariel Melendez <[email protected]>
  • Loading branch information
3 people authored Aug 17, 2021
1 parent 830dcce commit dab39cc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/blocs/sync/sync_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,13 @@ class SyncCubit extends Cubit<SyncState> {
.folderById(
driveId: driveId, folderId: treeRoot.folder.parentFolderId)
.map((f) => f.path)
.getSingle();
.getSingleOrNull();
}

await updateFolderTree(treeRoot, parentPath);
if (parentPath == null)
print('Missing parent folder: ' + treeRoot.folder.parentFolderId);
else
await updateFolderTree(treeRoot, parentPath);
}

// Update paths of files whose parent folders were not updated.
Expand Down

0 comments on commit dab39cc

Please sign in to comment.