diff --git a/lib/main.dart b/lib/main.dart index c8588f50d..d90f9e0ad 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -148,7 +148,7 @@ Future _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(); diff --git a/lib/utils/delete_file_util.dart b/lib/utils/delete_file_util.dart index e88096a1f..4d18faddd 100644 --- a/lib/utils/delete_file_util.dart +++ b/lib/utils/delete_file_util.dart @@ -274,7 +274,10 @@ Future> _tryDeleteSharedMediaFiles(List 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); diff --git a/lib/utils/local_settings.dart b/lib/utils/local_settings.dart index 28fced4f4..db5a19ab4 100644 --- a/lib/utils/local_settings.dart +++ b/lib/utils/local_settings.dart @@ -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); } }