mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 16:07:58 -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 scanDir?.delete(recursive: true);
|
||||||
await tempDir.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 {
|
enum PaperlessDirectoryType {
|
||||||
|
|||||||
@@ -98,9 +98,7 @@ void main() async {
|
|||||||
final connectivityCubit = ConnectivityCubit(connectivityStatusService);
|
final connectivityCubit = ConnectivityCubit(connectivityStatusService);
|
||||||
|
|
||||||
// Remove temporarily downloaded files.
|
// Remove temporarily downloaded files.
|
||||||
for (var item in (await FileService.temporaryDirectory).listSync()) {
|
await FileService.clearDirectoryContent(PaperlessDirectoryType.temporary);
|
||||||
item.deleteSync(recursive: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load application settings and stored authentication data
|
// Load application settings and stored authentication data
|
||||||
await connectivityCubit.initialize();
|
await connectivityCubit.initialize();
|
||||||
|
|||||||
Reference in New Issue
Block a user