Fix ListAlbum exception if dir does not exist

This commit is contained in:
Ming Ming 2021-09-05 19:07:42 +08:00
parent 394864e8ae
commit 1102ffd67c

View file

@ -247,8 +247,17 @@ class ListAlbumBloc extends Bloc<ListAlbumBlocEvent, ListAlbumBlocState> {
}
final shareRepo = ShareRepo(ShareRemoteDataSource());
final shares = await shareRepo.listDir(ev.account,
File(path: remote_storage_util.getRemoteAlbumsDir(ev.account)));
var shares = <Share>[];
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);