mirror of
https://github.com/immich-app/immich.git
synced 2025-11-27 00:35:16 -05:00
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>
This commit is contained in:
parent
d310c6f3cd
commit
38d4d1a573
@ -3,8 +3,6 @@ class ExifInfo {
|
|||||||
final int? fileSize;
|
final int? fileSize;
|
||||||
final String? description;
|
final String? description;
|
||||||
final bool isFlipped;
|
final bool isFlipped;
|
||||||
final double? width;
|
|
||||||
final double? height;
|
|
||||||
final String? orientation;
|
final String? orientation;
|
||||||
final String? timeZone;
|
final String? timeZone;
|
||||||
final DateTime? dateTimeOriginal;
|
final DateTime? dateTimeOriginal;
|
||||||
@ -46,8 +44,6 @@ class ExifInfo {
|
|||||||
this.fileSize,
|
this.fileSize,
|
||||||
this.description,
|
this.description,
|
||||||
this.orientation,
|
this.orientation,
|
||||||
this.width,
|
|
||||||
this.height,
|
|
||||||
this.timeZone,
|
this.timeZone,
|
||||||
this.dateTimeOriginal,
|
this.dateTimeOriginal,
|
||||||
this.isFlipped = false,
|
this.isFlipped = false,
|
||||||
@ -72,8 +68,6 @@ class ExifInfo {
|
|||||||
return other.fileSize == fileSize &&
|
return other.fileSize == fileSize &&
|
||||||
other.description == description &&
|
other.description == description &&
|
||||||
other.isFlipped == isFlipped &&
|
other.isFlipped == isFlipped &&
|
||||||
other.width == width &&
|
|
||||||
other.height == height &&
|
|
||||||
other.orientation == orientation &&
|
other.orientation == orientation &&
|
||||||
other.timeZone == timeZone &&
|
other.timeZone == timeZone &&
|
||||||
other.dateTimeOriginal == dateTimeOriginal &&
|
other.dateTimeOriginal == dateTimeOriginal &&
|
||||||
@ -98,8 +92,6 @@ class ExifInfo {
|
|||||||
description.hashCode ^
|
description.hashCode ^
|
||||||
orientation.hashCode ^
|
orientation.hashCode ^
|
||||||
isFlipped.hashCode ^
|
isFlipped.hashCode ^
|
||||||
width.hashCode ^
|
|
||||||
height.hashCode ^
|
|
||||||
timeZone.hashCode ^
|
timeZone.hashCode ^
|
||||||
dateTimeOriginal.hashCode ^
|
dateTimeOriginal.hashCode ^
|
||||||
latitude.hashCode ^
|
latitude.hashCode ^
|
||||||
@ -123,8 +115,6 @@ class ExifInfo {
|
|||||||
fileSize: ${fileSize ?? 'NA'},
|
fileSize: ${fileSize ?? 'NA'},
|
||||||
description: ${description ?? 'NA'},
|
description: ${description ?? 'NA'},
|
||||||
orientation: ${orientation ?? 'NA'},
|
orientation: ${orientation ?? 'NA'},
|
||||||
width: ${width ?? 'NA'},
|
|
||||||
height: ${height ?? 'NA'},
|
|
||||||
isFlipped: $isFlipped,
|
isFlipped: $isFlipped,
|
||||||
timeZone: ${timeZone ?? 'NA'},
|
timeZone: ${timeZone ?? 'NA'},
|
||||||
dateTimeOriginal: ${dateTimeOriginal ?? 'NA'},
|
dateTimeOriginal: ${dateTimeOriginal ?? 'NA'},
|
||||||
|
|||||||
@ -65,8 +65,8 @@ class AssetService {
|
|||||||
if (asset.hasRemote) {
|
if (asset.hasRemote) {
|
||||||
final exif = await getExif(asset);
|
final exif = await getExif(asset);
|
||||||
isFlipped = ExifDtoConverter.isOrientationFlipped(exif?.orientation);
|
isFlipped = ExifDtoConverter.isOrientationFlipped(exif?.orientation);
|
||||||
width = exif?.width ?? asset.width?.toDouble();
|
width = asset.width?.toDouble();
|
||||||
height = exif?.height ?? asset.height?.toDouble();
|
height = asset.height?.toDouble();
|
||||||
} else if (asset is LocalAsset) {
|
} else if (asset is LocalAsset) {
|
||||||
isFlipped = CurrentPlatform.isAndroid && (asset.orientation == 90 || asset.orientation == 270);
|
isFlipped = CurrentPlatform.isAndroid && (asset.orientation == 90 || asset.orientation == 270);
|
||||||
width = asset.width?.toDouble();
|
width = asset.width?.toDouble();
|
||||||
|
|||||||
@ -165,8 +165,6 @@ extension RemoteExifEntityDataDomainEx on RemoteExifEntityData {
|
|||||||
f: fNumber?.toDouble(),
|
f: fNumber?.toDouble(),
|
||||||
mm: focalLength?.toDouble(),
|
mm: focalLength?.toDouble(),
|
||||||
lens: lens,
|
lens: lens,
|
||||||
width: width?.toDouble(),
|
|
||||||
height: height?.toDouble(),
|
|
||||||
isFlipped: ExifDtoConverter.isOrientationFlipped(orientation),
|
isFlipped: ExifDtoConverter.isOrientationFlipped(orientation),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -219,8 +219,6 @@ class SyncStreamRepository extends DriftDatabaseRepository {
|
|||||||
country: Value(exif.country),
|
country: Value(exif.country),
|
||||||
dateTimeOriginal: Value(exif.dateTimeOriginal),
|
dateTimeOriginal: Value(exif.dateTimeOriginal),
|
||||||
description: Value(exif.description),
|
description: Value(exif.description),
|
||||||
height: Value(exif.exifImageHeight),
|
|
||||||
width: Value(exif.exifImageWidth),
|
|
||||||
exposureTime: Value(exif.exposureTime),
|
exposureTime: Value(exif.exposureTime),
|
||||||
fNumber: Value(exif.fNumber),
|
fNumber: Value(exif.fNumber),
|
||||||
fileSize: Value(exif.fileSizeInByte),
|
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) {
|
} catch (error, stack) {
|
||||||
_logger.severe('Error: updateAssetsExifV1 - $debugLabel', error, stack);
|
_logger.severe('Error: updateAssetsExifV1 - $debugLabel', error, stack);
|
||||||
rethrow;
|
rethrow;
|
||||||
|
|||||||
@ -161,8 +161,6 @@ class _AssetPropertiesSectionState extends ConsumerState<_AssetPropertiesSection
|
|||||||
value: exif.fileSize != null ? '${(exif.fileSize! / 1024 / 1024).toStringAsFixed(2)} MB' : null,
|
value: exif.fileSize != null ? '${(exif.fileSize! / 1024 / 1024).toStringAsFixed(2)} MB' : null,
|
||||||
),
|
),
|
||||||
_PropertyItem(label: 'Description', value: exif.description),
|
_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: 'Date Taken', value: exif.dateTimeOriginal?.toString()),
|
||||||
_PropertyItem(label: 'Time Zone', value: exif.timeZone),
|
_PropertyItem(label: 'Time Zone', value: exif.timeZone),
|
||||||
_PropertyItem(label: 'Camera Make', value: exif.make),
|
_PropertyItem(label: 'Camera Make', value: exif.make),
|
||||||
|
|||||||
@ -97,8 +97,8 @@ class _AssetDetailBottomSheet extends ConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _getFileInfo(BaseAsset asset, ExifInfo? exifInfo) {
|
String _getFileInfo(BaseAsset asset, ExifInfo? exifInfo) {
|
||||||
final height = asset.height ?? exifInfo?.height;
|
final height = asset.height;
|
||||||
final width = asset.width ?? exifInfo?.width;
|
final width = asset.width;
|
||||||
final resolution = (width != null && height != null) ? "${width.toInt()} x ${height.toInt()}" : null;
|
final resolution = (width != null && height != null) ? "${width.toInt()} x ${height.toInt()}" : null;
|
||||||
final fileSize = exifInfo?.fileSize != null ? formatBytes(exifInfo!.fileSize!) : null;
|
final fileSize = exifInfo?.fileSize != null ? formatBytes(exifInfo!.fileSize!) : null;
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ import 'package:isar/isar.dart';
|
|||||||
// ignore: import_rule_photo_manager
|
// ignore: import_rule_photo_manager
|
||||||
import 'package:photo_manager/photo_manager.dart';
|
import 'package:photo_manager/photo_manager.dart';
|
||||||
|
|
||||||
const int targetVersion = 17;
|
const int targetVersion = 18;
|
||||||
|
|
||||||
Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
|
Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
|
||||||
final hasVersion = Store.tryGet(StoreKey.version) != null;
|
final hasVersion = Store.tryGet(StoreKey.version) != null;
|
||||||
@ -63,7 +63,8 @@ Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
|
|||||||
await Store.populateCache();
|
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) {
|
if (version < 17 && Store.isBetaTimelineEnabled) {
|
||||||
final delay = Store.get(StoreKey.backupTriggerDelay, AppSettingsEnum.backupTriggerDelay.defaultValue);
|
final delay = Store.get(StoreKey.backupTriggerDelay, AppSettingsEnum.backupTriggerDelay.defaultValue);
|
||||||
@ -72,6 +73,11 @@ Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (version < 18 && Store.isBetaTimelineEnabled) {
|
||||||
|
await syncStreamRepository.reset();
|
||||||
|
await Store.put(StoreKey.shouldResetSync, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (targetVersion >= 12) {
|
if (targetVersion >= 12) {
|
||||||
await Store.put(StoreKey.version, targetVersion);
|
await Store.put(StoreKey.version, targetVersion);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user