Merge pull request #33 from ente-io/handle_deleted_files_from_cache
Gracefully handle deletion of files in app cache
This commit is contained in:
commit
d5dc4e23d9
3 changed files with 7 additions and 4 deletions
|
@ -148,7 +148,7 @@ Future<void> _init(bool isBackground) async {
|
|||
await RemoteSyncService.instance.init();
|
||||
await SyncService.instance.init();
|
||||
await MemoriesService.instance.init();
|
||||
LocalSettings.instance.init();
|
||||
await LocalSettings.instance.init();
|
||||
FeatureFlagService.instance.init();
|
||||
_logger.info("Initialization done");
|
||||
_initializationStatus.complete();
|
||||
|
|
|
@ -274,7 +274,10 @@ Future<List<String>> _tryDeleteSharedMediaFiles(List<String> localIDs) {
|
|||
"/" +
|
||||
id.replaceAll(kSharedMediaIdentifier, '');
|
||||
try {
|
||||
await io.File(localPath).delete();
|
||||
// verify the file exists as the OS may have already deleted it from cache
|
||||
if (io.File(localPath).existsSync()) {
|
||||
await io.File(localPath).delete();
|
||||
}
|
||||
actuallyDeletedIDs.add(id);
|
||||
} catch (e, s) {
|
||||
_logger.warning("Could not delete file " + id, e, s);
|
||||
|
|
|
@ -18,11 +18,11 @@ class LocalSettings {
|
|||
}
|
||||
|
||||
AlbumSortKey albumSortKey() {
|
||||
return AlbumSortKey.values[_prefs?.getInt(kCollectionSortPref) ?? 0] ??
|
||||
return AlbumSortKey.values[_prefs.getInt(kCollectionSortPref) ?? 0] ??
|
||||
AlbumSortKey.lastUpdated;
|
||||
}
|
||||
|
||||
void setAlbumSortKey(AlbumSortKey key) {
|
||||
_prefs?.setInt(kCollectionSortPref, key.index);
|
||||
_prefs.setInt(kCollectionSortPref, key.index);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue