From 38d4d1a5736239a7f2b75ffbc196fa5709354801 Mon Sep 17 00:00:00 2001 From: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> Date: Wed, 19 Nov 2025 08:25:01 +0530 Subject: [PATCH] chore: reset remote sync on app update (#23969) reset remote sync on update Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> --- mobile/lib/domain/models/exif.model.dart | 10 ---------- mobile/lib/domain/services/asset.service.dart | 4 ++-- mobile/lib/infrastructure/entities/exif.entity.dart | 2 -- .../repositories/sync_stream.repository.dart | 12 ++++++++++-- .../pages/drift_asset_troubleshoot.page.dart | 2 -- .../widgets/asset_viewer/bottom_sheet.widget.dart | 4 ++-- mobile/lib/utils/migration.dart | 10 ++++++++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/mobile/lib/domain/models/exif.model.dart b/mobile/lib/domain/models/exif.model.dart index 6e94c44650..84456b6dcc 100644 --- a/mobile/lib/domain/models/exif.model.dart +++ b/mobile/lib/domain/models/exif.model.dart @@ -3,8 +3,6 @@ class ExifInfo { final int? fileSize; final String? description; final bool isFlipped; - final double? width; - final double? height; final String? orientation; final String? timeZone; final DateTime? dateTimeOriginal; @@ -46,8 +44,6 @@ class ExifInfo { this.fileSize, this.description, this.orientation, - this.width, - this.height, this.timeZone, this.dateTimeOriginal, this.isFlipped = false, @@ -72,8 +68,6 @@ class ExifInfo { return other.fileSize == fileSize && other.description == description && other.isFlipped == isFlipped && - other.width == width && - other.height == height && other.orientation == orientation && other.timeZone == timeZone && other.dateTimeOriginal == dateTimeOriginal && @@ -98,8 +92,6 @@ class ExifInfo { description.hashCode ^ orientation.hashCode ^ isFlipped.hashCode ^ - width.hashCode ^ - height.hashCode ^ timeZone.hashCode ^ dateTimeOriginal.hashCode ^ latitude.hashCode ^ @@ -123,8 +115,6 @@ class ExifInfo { fileSize: ${fileSize ?? 'NA'}, description: ${description ?? 'NA'}, orientation: ${orientation ?? 'NA'}, -width: ${width ?? 'NA'}, -height: ${height ?? 'NA'}, isFlipped: $isFlipped, timeZone: ${timeZone ?? 'NA'}, dateTimeOriginal: ${dateTimeOriginal ?? 'NA'}, diff --git a/mobile/lib/domain/services/asset.service.dart b/mobile/lib/domain/services/asset.service.dart index 7f8ade313c..33661105e4 100644 --- a/mobile/lib/domain/services/asset.service.dart +++ b/mobile/lib/domain/services/asset.service.dart @@ -65,8 +65,8 @@ class AssetService { if (asset.hasRemote) { final exif = await getExif(asset); isFlipped = ExifDtoConverter.isOrientationFlipped(exif?.orientation); - width = exif?.width ?? asset.width?.toDouble(); - height = exif?.height ?? asset.height?.toDouble(); + width = asset.width?.toDouble(); + height = asset.height?.toDouble(); } else if (asset is LocalAsset) { isFlipped = CurrentPlatform.isAndroid && (asset.orientation == 90 || asset.orientation == 270); width = asset.width?.toDouble(); diff --git a/mobile/lib/infrastructure/entities/exif.entity.dart b/mobile/lib/infrastructure/entities/exif.entity.dart index 9c7f9e9975..f858e8b463 100644 --- a/mobile/lib/infrastructure/entities/exif.entity.dart +++ b/mobile/lib/infrastructure/entities/exif.entity.dart @@ -165,8 +165,6 @@ extension RemoteExifEntityDataDomainEx on RemoteExifEntityData { f: fNumber?.toDouble(), mm: focalLength?.toDouble(), lens: lens, - width: width?.toDouble(), - height: height?.toDouble(), isFlipped: ExifDtoConverter.isOrientationFlipped(orientation), ); } diff --git a/mobile/lib/infrastructure/repositories/sync_stream.repository.dart b/mobile/lib/infrastructure/repositories/sync_stream.repository.dart index 8e087f836f..5ab1844571 100644 --- a/mobile/lib/infrastructure/repositories/sync_stream.repository.dart +++ b/mobile/lib/infrastructure/repositories/sync_stream.repository.dart @@ -219,8 +219,6 @@ class SyncStreamRepository extends DriftDatabaseRepository { country: Value(exif.country), dateTimeOriginal: Value(exif.dateTimeOriginal), description: Value(exif.description), - height: Value(exif.exifImageHeight), - width: Value(exif.exifImageWidth), exposureTime: Value(exif.exposureTime), fNumber: Value(exif.fNumber), fileSize: Value(exif.fileSizeInByte), @@ -244,6 +242,16 @@ class SyncStreamRepository extends DriftDatabaseRepository { ); } }); + + await _db.batch((batch) { + for (final exif in data) { + batch.update( + _db.remoteAssetEntity, + RemoteAssetEntityCompanion(width: Value(exif.exifImageWidth), height: Value(exif.exifImageHeight)), + where: (row) => row.id.equals(exif.assetId), + ); + } + }); } catch (error, stack) { _logger.severe('Error: updateAssetsExifV1 - $debugLabel', error, stack); rethrow; diff --git a/mobile/lib/presentation/pages/drift_asset_troubleshoot.page.dart b/mobile/lib/presentation/pages/drift_asset_troubleshoot.page.dart index 7a899f4e72..752ab5ba37 100644 --- a/mobile/lib/presentation/pages/drift_asset_troubleshoot.page.dart +++ b/mobile/lib/presentation/pages/drift_asset_troubleshoot.page.dart @@ -161,8 +161,6 @@ class _AssetPropertiesSectionState extends ConsumerState<_AssetPropertiesSection value: exif.fileSize != null ? '${(exif.fileSize! / 1024 / 1024).toStringAsFixed(2)} MB' : null, ), _PropertyItem(label: 'Description', value: exif.description), - _PropertyItem(label: 'EXIF Width', value: exif.width?.toString()), - _PropertyItem(label: 'EXIF Height', value: exif.height?.toString()), _PropertyItem(label: 'Date Taken', value: exif.dateTimeOriginal?.toString()), _PropertyItem(label: 'Time Zone', value: exif.timeZone), _PropertyItem(label: 'Camera Make', value: exif.make), diff --git a/mobile/lib/presentation/widgets/asset_viewer/bottom_sheet.widget.dart b/mobile/lib/presentation/widgets/asset_viewer/bottom_sheet.widget.dart index d29e09a247..c7c502194a 100644 --- a/mobile/lib/presentation/widgets/asset_viewer/bottom_sheet.widget.dart +++ b/mobile/lib/presentation/widgets/asset_viewer/bottom_sheet.widget.dart @@ -97,8 +97,8 @@ class _AssetDetailBottomSheet extends ConsumerWidget { } String _getFileInfo(BaseAsset asset, ExifInfo? exifInfo) { - final height = asset.height ?? exifInfo?.height; - final width = asset.width ?? exifInfo?.width; + final height = asset.height; + final width = asset.width; final resolution = (width != null && height != null) ? "${width.toInt()} x ${height.toInt()}" : null; final fileSize = exifInfo?.fileSize != null ? formatBytes(exifInfo!.fileSize!) : null; diff --git a/mobile/lib/utils/migration.dart b/mobile/lib/utils/migration.dart index 2ed6d9549f..b0d7ea6013 100644 --- a/mobile/lib/utils/migration.dart +++ b/mobile/lib/utils/migration.dart @@ -29,7 +29,7 @@ import 'package:isar/isar.dart'; // ignore: import_rule_photo_manager import 'package:photo_manager/photo_manager.dart'; -const int targetVersion = 17; +const int targetVersion = 18; Future migrateDatabaseIfNeeded(Isar db, Drift drift) async { final hasVersion = Store.tryGet(StoreKey.version) != null; @@ -63,7 +63,8 @@ Future migrateDatabaseIfNeeded(Isar db, Drift drift) async { await Store.populateCache(); } - await handleBetaMigration(version, await _isNewInstallation(db, drift), SyncStreamRepository(drift)); + final syncStreamRepository = SyncStreamRepository(drift); + await handleBetaMigration(version, await _isNewInstallation(db, drift), syncStreamRepository); if (version < 17 && Store.isBetaTimelineEnabled) { final delay = Store.get(StoreKey.backupTriggerDelay, AppSettingsEnum.backupTriggerDelay.defaultValue); @@ -72,6 +73,11 @@ Future migrateDatabaseIfNeeded(Isar db, Drift drift) async { } } + if (version < 18 && Store.isBetaTimelineEnabled) { + await syncStreamRepository.reset(); + await Store.put(StoreKey.shouldResetSync, true); + } + if (targetVersion >= 12) { await Store.put(StoreKey.version, targetVersion); return;