mirror of
https://github.com/immich-app/immich.git
synced 2026-07-10 06:03:14 -07:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 215559d86a |
@@ -174,9 +174,10 @@ open class NativeSyncApiImplBase(context: Context) : ImmichPlugin(), ActivityAwa
|
|||||||
MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO -> 2L
|
MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO -> 2L
|
||||||
else -> 0L
|
else -> 0L
|
||||||
}
|
}
|
||||||
// Date taken is milliseconds since epoch, Date added is seconds since epoch
|
// Date taken is in ms; date added/modified in seconds. No-EXIF (date taken <= 0)
|
||||||
|
// falls back to the earliest of modified/added to match the server + iOS.
|
||||||
val createdAt = (c.getLong(dateTakenColumn).takeIf { it > 0 }?.div(1000))
|
val createdAt = (c.getLong(dateTakenColumn).takeIf { it > 0 }?.div(1000))
|
||||||
?: c.getLong(dateAddedColumn)
|
?: minOf(c.getLong(dateModifiedColumn), c.getLong(dateAddedColumn))
|
||||||
// Date modified is seconds since epoch
|
// Date modified is seconds since epoch
|
||||||
val modifiedAt = c.getLong(dateModifiedColumn)
|
val modifiedAt = c.getLong(dateModifiedColumn)
|
||||||
val width = c.getInt(widthColumn).toLong()
|
val width = c.getInt(widthColumn).toLong()
|
||||||
|
|||||||
@@ -12,13 +12,14 @@ import 'package:immich_mobile/domain/models/settings_key.dart';
|
|||||||
import 'package:immich_mobile/domain/models/store.model.dart';
|
import 'package:immich_mobile/domain/models/store.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/timeline.model.dart';
|
import 'package:immich_mobile/domain/models/timeline.model.dart';
|
||||||
import 'package:immich_mobile/entities/store.entity.dart';
|
import 'package:immich_mobile/entities/store.entity.dart';
|
||||||
|
import 'package:immich_mobile/extensions/platform_extensions.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/settings.entity.drift.dart';
|
import 'package:immich_mobile/infrastructure/entities/settings.entity.drift.dart';
|
||||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
||||||
import 'package:immich_mobile/infrastructure/repositories/network.repository.dart';
|
import 'package:immich_mobile/infrastructure/repositories/network.repository.dart';
|
||||||
import 'package:immich_mobile/models/auth/auxilary_endpoint.model.dart';
|
import 'package:immich_mobile/models/auth/auxilary_endpoint.model.dart';
|
||||||
import 'package:immich_mobile/providers/album/album_sort_by_options.provider.dart';
|
import 'package:immich_mobile/providers/album/album_sort_by_options.provider.dart';
|
||||||
|
|
||||||
const int targetVersion = 26;
|
const int targetVersion = 27;
|
||||||
|
|
||||||
Future<void> migrateDatabaseIfNeeded(Drift drift) async {
|
Future<void> migrateDatabaseIfNeeded(Drift drift) async {
|
||||||
final int version = Store.get(StoreKey.version, targetVersion);
|
final int version = Store.get(StoreKey.version, targetVersion);
|
||||||
@@ -31,10 +32,33 @@ Future<void> migrateDatabaseIfNeeded(Drift drift) async {
|
|||||||
await _migrateTo26(drift);
|
await _migrateTo26(drift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (version < 27) {
|
||||||
|
if (!await _migrateTo27(drift)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await Store.put(StoreKey.version, targetVersion);
|
await Store.put(StoreKey.version, targetVersion);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> _migrateTo27(Drift drift) async {
|
||||||
|
// Android-only: no-EXIF photos got a wrong createdAt (DATE_ADDED copy-time instead
|
||||||
|
// of the real DATE_MODIFIED). Those rows can't self-heal -- the local sync only
|
||||||
|
// updates an asset when its updatedAt (DATE_MODIFIED) changes, which it never does
|
||||||
|
// here. A createdAt later than updatedAt is the copy-time signature, so clamp it
|
||||||
|
// back to updatedAt (the real date, == the new minOf(DATE_MODIFIED, DATE_ADDED)).
|
||||||
|
if (!CurrentPlatform.isAndroid) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await drift.customStatement('UPDATE local_asset_entity SET created_at = updated_at WHERE created_at > updated_at');
|
||||||
|
return true;
|
||||||
|
} catch (_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _migrateTo25() async {
|
Future<void> _migrateTo25() async {
|
||||||
final accessToken = Store.tryGet(StoreKey.accessToken);
|
final accessToken = Store.tryGet(StoreKey.accessToken);
|
||||||
if (accessToken == null || accessToken.isEmpty) {
|
if (accessToken == null || accessToken.isEmpty) {
|
||||||
|
|||||||
Reference in New Issue
Block a user