mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 06:07:57 -06:00
Extracted to function and added check if dir exists
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -98,9 +98,7 @@ void main() async {
|
||||
final connectivityCubit = ConnectivityCubit(connectivityStatusService);
|
||||
|
||||
// Remove temporarily downloaded files.
|
||||
for (var item in (await FileService.temporaryDirectory).listSync()) {
|
||||
item.deleteSync(recursive: true);
|
||||
}
|
||||
await FileService.clearDirectoryContent(PaperlessDirectoryType.temporary);
|
||||
|
||||
// Load application settings and stored authentication data
|
||||
await connectivityCubit.initialize();
|
||||
|
||||
Reference in New Issue
Block a user