mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-28 18:01:35 +01:00
Remove options to include root in Ls
This commit is contained in:
parent
62396a91a4
commit
c26fa28594
2 changed files with 8 additions and 40 deletions
|
@ -7,20 +7,14 @@ class Ls {
|
|||
|
||||
/// List all files under a dir
|
||||
///
|
||||
/// The resulting list would normally also include the [root] dir. If
|
||||
/// [shouldExcludeRootDir] == true, such entry will be removed
|
||||
Future<List<File>> call(Account account, File root,
|
||||
{bool shouldExcludeRootDir = true}) async {
|
||||
final products = await fileRepo.list(account, root);
|
||||
if (shouldExcludeRootDir) {
|
||||
// filter out root file
|
||||
final trimmedRootPath = root.path.trimAny("/");
|
||||
return products
|
||||
.where((element) => element.path.trimAny("/") != trimmedRootPath)
|
||||
.toList();
|
||||
} else {
|
||||
return products;
|
||||
}
|
||||
/// 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();
|
||||
}
|
||||
|
||||
final FileRepo fileRepo;
|
||||
|
|
|
@ -29,32 +29,6 @@ void main() {
|
|||
),
|
||||
]);
|
||||
});
|
||||
|
||||
test("shouldExcludeRootDir == false", () async {
|
||||
expect(
|
||||
await Ls(_MockFileRepo())(
|
||||
util.buildAccount(),
|
||||
File(
|
||||
path: "remote.php/dav/files/admin",
|
||||
),
|
||||
shouldExcludeRootDir: false),
|
||||
[
|
||||
File(
|
||||
path: "remote.php/dav/files/admin",
|
||||
isCollection: true,
|
||||
),
|
||||
File(
|
||||
path: "remote.php/dav/files/admin/test1.jpg",
|
||||
),
|
||||
File(
|
||||
path: "remote.php/dav/files/admin/test2.jpg",
|
||||
),
|
||||
File(
|
||||
path: "remote.php/dav/files/admin/d1",
|
||||
isCollection: true,
|
||||
),
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue