diff --git a/app/lib/bloc/ls_dir.dart b/app/lib/bloc/ls_dir.dart index 320a5082..9eb7af6a 100644 --- a/app/lib/bloc/ls_dir.dart +++ b/app/lib/bloc/ls_dir.dart @@ -8,7 +8,7 @@ import 'package:nc_photos/exception.dart'; import 'package:nc_photos/use_case/ls.dart'; class LsDirBlocItem with EquatableMixin { - LsDirBlocItem(this.file, this.children); + LsDirBlocItem(this.file, this.isE2ee, this.children); @override toString({bool isDeep = false}) { @@ -41,6 +41,7 @@ class LsDirBlocItem with EquatableMixin { ]; final File file; + final bool isE2ee; /// Child directories under this directory /// @@ -183,13 +184,17 @@ class LsDirBloc extends Bloc { if (ev.depth > 1) { children = await _query(ev.copyWith(root: f, depth: ev.depth - 1)); } - product.add(LsDirBlocItem(f, children)); + product.add(LsDirBlocItem(f, false, children)); } on ApiException catch (e) { if (e.response.statusCode == 404) { // this could happen when the server db contains dangling entries _log.warning( "[call] HTTP404 error while listing dir: ${logFilename(f.path)}"); removes.add(f); + } else if (f.isCollection == true && e.response.statusCode == 403) { + // e2ee dir + _log.warning("[call] HTTP403 error, likely E2EE dir: ${f.path}"); + product.add(LsDirBlocItem(f, true, [])); } else { rethrow; } diff --git a/app/lib/widget/dir_picker.dart b/app/lib/widget/dir_picker.dart index 1c9d44c9..ad6bc295 100644 --- a/app/lib/widget/dir_picker.dart +++ b/app/lib/widget/dir_picker.dart @@ -11,6 +11,7 @@ import 'package:nc_photos/entity/file_util.dart' as file_util; import 'package:nc_photos/exception_util.dart' as exception_util; import 'package:nc_photos/k.dart' as k; import 'package:nc_photos/snack_bar_manager.dart'; +import 'package:nc_photos/theme.dart'; import 'package:path/path.dart' as path_lib; class DirPicker extends StatefulWidget { @@ -41,7 +42,7 @@ class DirPickerState extends State { @override initState() { super.initState(); - _root = LsDirBlocItem(File(path: _rootDir), []); + _root = LsDirBlocItem(File(path: _rootDir), false, []); _initBloc(); if (widget.initialPicks != null) { _picks.addAll(widget.initialPicks!); @@ -127,7 +128,7 @@ class DirPickerState extends State { context, state.items[index - (isTopLevel ? 0 : 1)]); } }, - separatorBuilder: (context, index) => const Divider(), + separatorBuilder: (context, index) => const Divider(height: 2), itemCount: state.items.length + (isTopLevel ? 0 : 1), ), ), @@ -135,7 +136,7 @@ class DirPickerState extends State { } Widget _buildItem(BuildContext context, LsDirBlocItem item) { - final canPick = widget.validator?.call(item.file) != false; + final canPick = !item.isE2ee && widget.validator?.call(item.file) != false; final pickState = _isItemPicked(item); IconData? iconData; @@ -158,9 +159,12 @@ class DirPickerState extends State { : Icons.radio_button_unchecked; break; } + } else if (item.isE2ee) { + iconData = Icons.lock_outlined; } return ListTile( + contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), dense: true, leading: canPick ? IconButton( @@ -181,14 +185,16 @@ class DirPickerState extends State { } }, ) - : const IconButton( - icon: Icon(null), + : IconButton( + icon: Icon(iconData), + color: AppTheme.getUnfocusedIconColor(context), onPressed: null, ), title: Text(item.file.filename), trailing: item.children?.isNotEmpty == true ? const Icon(Icons.arrow_forward_ios) : null, + textColor: item.isE2ee ? AppTheme.getUnfocusedIconColor(context) : null, onTap: item.children?.isNotEmpty == true ? () { try { diff --git a/app/test/bloc/ls_dir_test.dart b/app/test/bloc/ls_dir_test.dart index 9e3341ae..1134c16e 100644 --- a/app/test/bloc/ls_dir_test.dart +++ b/app/test/bloc/ls_dir_test.dart @@ -41,6 +41,7 @@ void main() { path: "remote.php/dav/files/admin/d1", isCollection: true, ), + false, null, ), ]), @@ -62,6 +63,7 @@ void main() { path: "remote.php/dav/files/admin/d1/d2-1", isCollection: true, ), + false, null, ), LsDirBlocItem( @@ -69,6 +71,7 @@ void main() { path: "remote.php/dav/files/admin/d1/d2-2", isCollection: true, ), + false, null, ), ]), @@ -104,12 +107,14 @@ void main() { path: "remote.php/dav/files/admin/d1", isCollection: true, ), + false, [ LsDirBlocItem( File( path: "remote.php/dav/files/admin/d1/d2-1", isCollection: true, ), + false, null, ), LsDirBlocItem( @@ -117,6 +122,7 @@ void main() { path: "remote.php/dav/files/admin/d1/d2-2", isCollection: true, ), + false, null, ), ],