mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Silently hide 404 dirs in LsDir
This commit is contained in:
parent
5a02643e54
commit
e7d0fd206a
1 changed files with 18 additions and 4 deletions
|
@ -3,6 +3,7 @@ import 'package:equatable/equatable.dart';
|
|||
import 'package:logging/logging.dart';
|
||||
import 'package:nc_photos/account.dart';
|
||||
import 'package:nc_photos/entity/file.dart';
|
||||
import 'package:nc_photos/exception.dart';
|
||||
import 'package:nc_photos/use_case/ls.dart';
|
||||
|
||||
class LsDirBlocItem with EquatableMixin {
|
||||
|
@ -174,12 +175,25 @@ class LsDirBloc extends Bloc<LsDirBlocEvent, LsDirBlocState> {
|
|||
.toList();
|
||||
_cache[ev.root.path] = files;
|
||||
}
|
||||
final removes = <File>[];
|
||||
for (final f in files) {
|
||||
List<LsDirBlocItem>? children;
|
||||
if (ev.depth > 1) {
|
||||
children = await _query(ev.copyWith(root: f, depth: ev.depth - 1));
|
||||
try {
|
||||
List<LsDirBlocItem>? children;
|
||||
if (ev.depth > 1) {
|
||||
children = await _query(ev.copyWith(root: f, depth: ev.depth - 1));
|
||||
}
|
||||
product.add(LsDirBlocItem(f, children));
|
||||
} on ApiException catch (e) {
|
||||
if (e.response.statusCode == 404) {
|
||||
// this could happen when the server db contains dangling entries
|
||||
removes.add(f);
|
||||
} else {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
product.add(LsDirBlocItem(f, children));
|
||||
}
|
||||
if (removes.isNotEmpty) {
|
||||
files.removeWhere((f) => removes.contains(f));
|
||||
}
|
||||
return product;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue