mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:04:16 -04:00
chore: catch migration error (#19096)
This commit is contained in:
parent
4b4ee5abf3
commit
b50d9fa448
@ -166,25 +166,33 @@ Future<void> _migrateDeviceAsset(Isar db) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _migrateDeviceAssetToSqlite(Isar db, Drift drift) async {
|
Future<void> _migrateDeviceAssetToSqlite(Isar db, Drift drift) async {
|
||||||
final isarDeviceAssets =
|
try {
|
||||||
await db.deviceAssetEntitys.where().sortByAssetId().findAll();
|
final isarDeviceAssets =
|
||||||
await drift.batch((batch) {
|
await db.deviceAssetEntitys.where().sortByAssetId().findAll();
|
||||||
for (final deviceAsset in isarDeviceAssets) {
|
await drift.batch((batch) {
|
||||||
final companion = LocalAssetEntityCompanion(
|
for (final deviceAsset in isarDeviceAssets) {
|
||||||
updatedAt: Value(deviceAsset.modifiedTime),
|
final companion = LocalAssetEntityCompanion(
|
||||||
id: Value(deviceAsset.assetId),
|
updatedAt: Value(deviceAsset.modifiedTime),
|
||||||
checksum: Value(base64.encode(deviceAsset.hash)),
|
id: Value(deviceAsset.assetId),
|
||||||
);
|
checksum: Value(base64.encode(deviceAsset.hash)),
|
||||||
batch.insert<$LocalAssetEntityTable, LocalAssetEntityData>(
|
);
|
||||||
drift.localAssetEntity,
|
batch.insert<$LocalAssetEntityTable, LocalAssetEntityData>(
|
||||||
companion,
|
drift.localAssetEntity,
|
||||||
onConflict: DoUpdate(
|
companion,
|
||||||
(_) => companion,
|
onConflict: DoUpdate(
|
||||||
where: (old) => old.updatedAt.equals(deviceAsset.modifiedTime),
|
(_) => companion,
|
||||||
),
|
where: (old) => old.updatedAt.equals(deviceAsset.modifiedTime),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
"[MIGRATION] Error while migrating device assets to SQLite: $error",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DeviceAsset {
|
class _DeviceAsset {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user