simplified code across the app and consolidated duplicated helpers

This commit is contained in:
2026-09-27 17:29:54 +02:00
parent 3e856d0b1c
commit ee1240f71a
155 changed files with 1772 additions and 2546 deletions
@@ -0,0 +1,26 @@
// Paths relative to the WebDAV root, as used by `CacheableFile.path`: no
// leading slash, folders end with '/', the root folder is ''.
final RegExp _edgeSlashes = RegExp(r'^/+|/+$');
List<String> webdavSegmentsOf(String path) {
final stripped = path.replaceAll(_edgeSlashes, '');
return stripped.isEmpty ? [] : stripped.split('/');
}
List<String> webdavParentSegmentsOf(String path) {
final segments = webdavSegmentsOf(path);
if (segments.isNotEmpty) segments.removeLast();
return segments;
}
String webdavFolderPath(List<String> segments) =>
segments.isEmpty ? '' : '${segments.join('/')}/';
String webdavJoin(String folder, String name, {required bool isDirectory}) =>
isDirectory ? '$folder$name/' : '$folder$name';
/// Folder key used by `ListFilesCache` and `FilesBloc`: no leading or
/// trailing slash, root is '/'.
String listFilesCacheKey(List<String> segments) =>
segments.isEmpty ? '/' : segments.join('/');