mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 10:28:50 +01:00
Fix potential stack overflow when querying lots of files
This commit is contained in:
parent
6b5f62d91c
commit
92980e4062
1 changed files with 11 additions and 8 deletions
|
@ -21,14 +21,17 @@ class ScanDirOffline {
|
|||
AppDbFile2Entry.toStrippedPathIndexLowerKeyForDir(account, root),
|
||||
AppDbFile2Entry.toStrippedPathIndexUpperKeyForDir(account, root),
|
||||
);
|
||||
return await index
|
||||
.openCursor(range: range, autoAdvance: true)
|
||||
.map((c) => c.value)
|
||||
.cast<Map>()
|
||||
.map(
|
||||
(e) => AppDbFile2Entry.fromJson(e.cast<String, dynamic>()).file)
|
||||
.where((f) => file_util.isSupportedFormat(f))
|
||||
.toList();
|
||||
final product = <File>[];
|
||||
await for (final c
|
||||
in index.openCursor(range: range, autoAdvance: false)) {
|
||||
final e = AppDbFile2Entry.fromJson(
|
||||
(c.value as Map).cast<String, dynamic>());
|
||||
if (file_util.isSupportedFormat(e.file)) {
|
||||
product.add(e.file);
|
||||
}
|
||||
c.next();
|
||||
}
|
||||
return product;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue