Extracted to function and added check if dir exists

This commit is contained in:
Tim-Luca Lagmöller
2023-01-31 13:26:26 +01:00
parent 20d19d33f7
commit 46be27e8ba
2 changed files with 11 additions and 3 deletions

View File

@@ -85,6 +85,16 @@ class FileService {
await scanDir?.delete(recursive: true);
await tempDir.delete(recursive: true);
}
static Future<void> clearDirectoryContent(PaperlessDirectoryType type) async {
final dir = await getDirectory(type);
if (dir == null || !(await dir.exists())) {
return;
}
await Future.wait(dir.listSync().map((item) => item.delete()));
}
}
enum PaperlessDirectoryType {