rebase main
This commit is contained in:
@@ -35,7 +35,7 @@ import 'package:logging/logging.dart';
|
||||
// ignore: import_rule_photo_manager
|
||||
import 'package:photo_manager/photo_manager.dart';
|
||||
|
||||
const int targetVersion = 14;
|
||||
const int targetVersion = 15;
|
||||
|
||||
Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
|
||||
final hasVersion = Store.tryGet(StoreKey.version) != null;
|
||||
@@ -70,6 +70,10 @@ Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
|
||||
await Store.populateCache();
|
||||
}
|
||||
|
||||
if (version < 15) {
|
||||
await _updateCloudId(drift);
|
||||
}
|
||||
|
||||
if (targetVersion >= 12) {
|
||||
await Store.put(StoreKey.version, targetVersion);
|
||||
return;
|
||||
@@ -179,6 +183,20 @@ Future<void> migrateDeviceAssetToSqlite(Isar db, Drift drift) async {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _updateCloudId(Drift drift) async {
|
||||
// Android do not have a concept of cloud IDs
|
||||
if (Platform.isAndroid) {
|
||||
return;
|
||||
}
|
||||
|
||||
final query = drift.localAssetEntity.selectOnly()
|
||||
..addColumns([drift.localAssetEntity.id])
|
||||
..where(drift.localAssetEntity.cloudId.isNull());
|
||||
final ids = await query.map((row) => row.read(drift.localAssetEntity.id)!).get();
|
||||
final cloudMapping = await NativeSyncApi().getCloudIdForAssetIds(ids);
|
||||
await DriftLocalAlbumRepository(drift).updateCloudMapping(cloudMapping);
|
||||
}
|
||||
|
||||
Future<void> migrateBackupAlbumsToSqlite(Isar db, Drift drift) async {
|
||||
try {
|
||||
final isarBackupAlbums = await db.backupAlbums.where().findAll();
|
||||
|
||||
Reference in New Issue
Block a user