2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/account.dart';
|
|
|
|
import 'package:nc_photos/entity/file.dart';
|
2023-08-25 18:37:17 +02:00
|
|
|
import 'package:np_string/np_string.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
|
|
|
|
class Ls {
|
|
|
|
Ls(this.fileRepo);
|
|
|
|
|
|
|
|
/// List all files under a dir
|
|
|
|
///
|
2022-01-01 17:29:10 +01:00
|
|
|
/// The dir itself is not included in the returned list
|
|
|
|
Future<List<File>> call(Account account, File dir) async {
|
|
|
|
final products = await fileRepo.list(account, dir);
|
|
|
|
// filter out root file
|
|
|
|
final trimmedRootPath = dir.path.trimAny("/");
|
|
|
|
return products
|
|
|
|
.where((element) => element.path.trimAny("/") != trimmedRootPath)
|
|
|
|
.toList();
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
final FileRepo fileRepo;
|
|
|
|
}
|
2022-07-25 11:45:57 +02:00
|
|
|
|
|
|
|
class LsMinimal implements Ls {
|
|
|
|
const LsMinimal(this.fileRepo);
|
|
|
|
|
|
|
|
/// List all files under a dir with minimal data
|
|
|
|
///
|
|
|
|
/// The dir itself is not included in the returned list
|
|
|
|
@override
|
|
|
|
Future<List<File>> call(Account account, File dir) async {
|
|
|
|
final products = await fileRepo.listMinimal(account, dir);
|
|
|
|
// filter out root file
|
|
|
|
final trimmedRootPath = dir.path.trimAny("/");
|
|
|
|
return products
|
|
|
|
.where((element) => element.path.trimAny("/") != trimmedRootPath)
|
|
|
|
.toList();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
final FileRepo fileRepo;
|
|
|
|
}
|