From c2775894e1a2f30b887e7e476e9c2526a8dced60 Mon Sep 17 00:00:00 2001 From: Brandon Wees Date: Fri, 23 Jan 2026 19:23:46 -0600 Subject: [PATCH] fix(mobile): backfill asset dimensions to exif table (#25483) --- .../repositories/sync_stream.repository.dart | 2 ++ mobile/lib/utils/migration.dart | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/mobile/lib/infrastructure/repositories/sync_stream.repository.dart b/mobile/lib/infrastructure/repositories/sync_stream.repository.dart index c92ce427d5..26f89432a5 100644 --- a/mobile/lib/infrastructure/repositories/sync_stream.repository.dart +++ b/mobile/lib/infrastructure/repositories/sync_stream.repository.dart @@ -240,6 +240,8 @@ class SyncStreamRepository extends DriftDatabaseRepository { rating: Value(exif.rating), projectionType: Value(exif.projectionType), lens: Value(exif.lensModel), + width: Value(exif.exifImageWidth), + height: Value(exif.exifImageHeight), ); batch.insert( diff --git a/mobile/lib/utils/migration.dart b/mobile/lib/utils/migration.dart index 30a9702b53..56a95c889f 100644 --- a/mobile/lib/utils/migration.dart +++ b/mobile/lib/utils/migration.dart @@ -88,6 +88,7 @@ Future migrateDatabaseIfNeeded(Isar db, Drift drift) async { if (version < 20 && Store.isBetaTimelineEnabled) { await _syncLocalAlbumIsIosSharedAlbum(drift); + await _backfillAssetExifWidthHeight(drift); } if (targetVersion >= 12) { @@ -281,6 +282,22 @@ Future _syncLocalAlbumIsIosSharedAlbum(Drift db) async { } } +Future _backfillAssetExifWidthHeight(Drift db) async { + try { + await db.customStatement(''' + UPDATE remote_exif_entity AS remote_exif + SET width = asset.width, + height = asset.height + FROM remote_asset_entity AS asset + WHERE remote_exif.asset_id = asset.id; + '''); + + dPrint(() => "[MIGRATION] Successfully backfilled asset exif width and height"); + } catch (error) { + dPrint(() => "[MIGRATION] Error while backfilling asset exif width and height: $error"); + } +} + Future migrateDeviceAssetToSqlite(Isar db, Drift drift) async { try { final isarDeviceAssets = await db.deviceAssetEntitys.where().findAll();