diff --git a/mobile/android/app/src/main/kotlin/app/alextran/immich/sync/MessagesImplBase.kt b/mobile/android/app/src/main/kotlin/app/alextran/immich/sync/MessagesImplBase.kt index f52dc60279..fc4eb8365a 100644 --- a/mobile/android/app/src/main/kotlin/app/alextran/immich/sync/MessagesImplBase.kt +++ b/mobile/android/app/src/main/kotlin/app/alextran/immich/sync/MessagesImplBase.kt @@ -174,8 +174,8 @@ open class NativeSyncApiImplBase(context: Context) : ImmichPlugin(), ActivityAwa MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO -> 2L else -> 0L } - // Date taken is in ms; added/modified are in seconds. No-EXIF assets use the earliest - // positive modified/added date, or added if neither is positive. + // Date taken is in ms; added/modified are in seconds, and modified can be 0 when unset. + // No-EXIF assets use the earliest positive added/modified date, or raw added if neither is positive. val modifiedAt = c.getLong(dateModifiedColumn) val addedAt = c.getLong(dateAddedColumn) val createdAt = (c.getLong(dateTakenColumn).takeIf { it > 0 }?.div(1000)) diff --git a/mobile/test/modules/utils/migration_test.dart b/mobile/test/modules/utils/migration_test.dart index 8c050bf02f..fb7999d5c2 100644 --- a/mobile/test/modules/utils/migration_test.dart +++ b/mobile/test/modules/utils/migration_test.dart @@ -102,15 +102,32 @@ void main() { source: TrashOrigin.localSync, ), ); + await db + .into(db.trashedLocalAssetEntity) + .insert( + TrashedLocalAssetEntityCompanion.insert( + id: 'trashed-epoch', + albumId: 'album', + name: 'trashed-epoch.jpg', + type: AssetType.image, + createdAt: drift.Value(createdAt), + updatedAt: drift.Value(epoch), + source: TrashOrigin.localSync, + ), + ); await migrateDatabaseIfNeeded(db); final local = await (db.select(db.localAssetEntity)..where((row) => row.id.equals('local'))).getSingle(); final unchanged = await (db.select(db.localAssetEntity)..where((row) => row.id.equals('epoch'))).getSingle(); - final trashed = await db.select(db.trashedLocalAssetEntity).getSingle(); + final trashed = await (db.select(db.trashedLocalAssetEntity)..where((row) => row.id.equals('trashed'))).getSingle(); + final trashedUnchanged = await (db.select( + db.trashedLocalAssetEntity, + )..where((row) => row.id.equals('trashed-epoch'))).getSingle(); expect(local.createdAt, updatedAt); expect(unchanged.createdAt, createdAt); expect(trashed.createdAt, updatedAt); + expect(trashedUnchanged.createdAt, createdAt); expect(await storeRepository.tryGet(StoreKey.version), 27); }); }