From dab39ccfad07d457c7ccf51c4b87851963c1f54a Mon Sep 17 00:00:00 2001 From: arielmelendez Date: Tue, 17 Aug 2021 05:45:46 -0700 Subject: [PATCH] Properly handle a missing parent folder. (#188) 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 Co-authored-by: Ariel Melendez --- lib/blocs/sync/sync_cubit.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/blocs/sync/sync_cubit.dart b/lib/blocs/sync/sync_cubit.dart index c42ed32934..34bcb3d7d3 100644 --- a/lib/blocs/sync/sync_cubit.dart +++ b/lib/blocs/sync/sync_cubit.dart @@ -469,10 +469,13 @@ class SyncCubit extends Cubit { .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.