High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix: skip albums selected or excluded from backups from deletions (#21116)
shenlonged3997d844a4
diff --git a/mobile/lib/infrastructure/repositories/local_album.repository.dart b/mobile/lib/infrastructure/repositories/local_album.repository.dartindex 19495317d5..0c29768880 100644--- a/mobile/lib/infrastructure/repositories/local_album.repository.dart+++ b/mobile/lib/infrastructure/repositories/local_album.repository.dart@@ -56,8 +56,9 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {final assetsToDelete = _platform.isIOS ? await _getUniqueAssetsInAlbum(albumId) : await getAssetIds(albumId);await _deleteAssets(assetsToDelete);- // All the other assets that are still associated will be unlinked automatically on-cascade- await _db.managers.localAlbumEntity.filter((a) => a.id.equals(albumId)).delete();+ await _db.managers.localAlbumEntity+ .filter((a) => a.id.equals(albumId) & a.backupSelection.equals(BackupSelection.none))+ .delete();});Future<void> syncDeletes(String albumId, Iterable<String> assetIdsToKeep) async {@@ -152,7 +153,10 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {await deleteSmt.go();}- await _db.localAlbumEntity.deleteWhere((f) => f.marker_.isNotNull());+ // Only remove albums that are not explicitly selected or excluded from backups+ await _db.localAlbumEntity.deleteWhere(+ (f) => f.marker_.isNotNull() & f.backupSelection.equalsValue(BackupSelection.none),+ );});}diff --git a/mobile/lib/pages/common/tab_shell.page.dart b/mobile/lib/pages/common/tab_shell.page.dartindex 2c2c64fb25..983164831a 100644--- a/mobile/lib/pages/common/tab_shell.page.dart+++ b/mobile/lib/pages/common/tab_shell.page.dart@@ -134,6 +134,10 @@ void _onNavigationSelected(TabsRouter router, int index, WidgetRef ref) {ref.read(remoteAlbumProvider.notifier).refresh();}+ if (index == 3) {+ ref.invalidate(localAlbumProvider);+ }+ref.read(hapticFeedbackProvider.notifier).selectionClick();router.setActiveIndex(index);ref.read(tabProvider.notifier).state = TabEnum.values[index];diff --git a/mobile/lib/providers/infrastructure/album.provider.dart b/mobile/lib/providers/infrastructure/album.provider.dartindex 029d912155..8388480974 100644--- a/mobile/lib/providers/infrastructure/album.provider.dart+++ b/mobile/lib/providers/infrastructure/album.provider.dart@@ -18,7 +18,9 @@ final localAlbumServiceProvider = Provider<LocalAlbumService>();final localAlbumProvider = FutureProvider<List<LocalAlbum>>(- (ref) => LocalAlbumService(ref.watch(localAlbumRepository)).getAll(sortBy: {SortLocalAlbumsBy.newestAsset}),+ (ref) => LocalAlbumService(ref.watch(localAlbumRepository))+ .getAll(sortBy: {SortLocalAlbumsBy.newestAsset})+ .then((albums) => albums.where((album) => album.assetCount > 0).toList()),);final localAlbumThumbnailProvider = FutureProvider.family<LocalAsset?, String>(