From 1102ffd67c6a376a05971c0d8038fbff0ea990dd Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sun, 5 Sep 2021 19:07:42 +0800 Subject: [PATCH] Fix ListAlbum exception if dir does not exist --- lib/bloc/list_album.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/bloc/list_album.dart b/lib/bloc/list_album.dart index 1abd5a79..ac3bc007 100644 --- a/lib/bloc/list_album.dart +++ b/lib/bloc/list_album.dart @@ -247,8 +247,17 @@ class ListAlbumBloc extends Bloc { } final shareRepo = ShareRepo(ShareRemoteDataSource()); - final shares = await shareRepo.listDir(ev.account, - File(path: remote_storage_util.getRemoteAlbumsDir(ev.account))); + var shares = []; + try { + shares = await shareRepo.listDir(ev.account, + File(path: remote_storage_util.getRemoteAlbumsDir(ev.account))); + } on ApiException catch(e) { + if (e.response.statusCode == 404) { + // Normal when album dir is not created yet + } else { + rethrow; + } + } final items = albums.map((e) { final isSharedByMe = shares.any((element) => element.path.trimAny("/") == e.albumFile!.strippedPath);