Compare commits

...

7 Commits

Author SHA1 Message Date
shenlong-tanwen
da7554c92b soft reset 2026-01-28 18:19:36 +05:30
shenlong-tanwen
55622b9db0 chore: add log for client initiated reset 2026-01-28 17:59:03 +05:30
shenlong-tanwen
e462c144df full sync reset 2026-01-28 17:59:03 +05:30
shenlong-tanwen
cbac907807 reset asset backfills 2026-01-28 17:25:17 +05:30
shenlong-tanwen
c46f723631 reset asset sync entity on mobile and server 2026-01-28 16:45:45 +05:30
bwees
a69baa5f6a fix: test 2026-01-28 00:44:37 -06:00
bwees
082a82c48a fix(mobile): ensure flipped dimensions on asset table 2026-01-28 00:30:09 -06:00
5 changed files with 21 additions and 21 deletions

View File

@@ -36,6 +36,9 @@ class SyncApiRepository {
headers.addAll(headerParams);
final shouldReset = Store.get(StoreKey.shouldResetSync, false);
if (shouldReset) {
_logger.info("Resetting sync state by client");
}
final request = http.Request('POST', Uri.parse(endpoint));
request.headers.addAll(headers);
request.body = jsonEncode(

View File

@@ -268,7 +268,7 @@ class SyncStreamRepository extends DriftDatabaseRepository {
batch.update(
_db.remoteAssetEntity,
RemoteAssetEntityCompanion(width: Value(width), height: Value(height)),
where: (row) => row.id.equals(exif.assetId) & row.width.isNull() & row.height.isNull(),
where: (row) => row.id.equals(exif.assetId) & row.isEdited.equals(false),
);
}
});

View File

@@ -31,7 +31,7 @@ import 'package:isar/isar.dart';
// ignore: import_rule_photo_manager
import 'package:photo_manager/photo_manager.dart';
const int targetVersion = 20;
const int targetVersion = 21;
Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
final hasVersion = Store.tryGet(StoreKey.version) != null;
@@ -88,7 +88,10 @@ Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
if (version < 20 && Store.isBetaTimelineEnabled) {
await _syncLocalAlbumIsIosSharedAlbum(drift);
await _backfillAssetExifWidthHeight(drift);
}
if (version < 21) {
await Store.put(StoreKey.shouldResetSync, true);
}
if (targetVersion >= 12) {
@@ -282,22 +285,6 @@ Future<void> _syncLocalAlbumIsIosSharedAlbum(Drift db) async {
}
}
Future<void> _backfillAssetExifWidthHeight(Drift db) async {
try {
await db.customStatement('''
UPDATE remote_exif_entity AS remote_exif
SET width = asset.width,
height = asset.height
FROM remote_asset_entity AS asset
WHERE remote_exif.asset_id = asset.id;
''');
dPrint(() => "[MIGRATION] Successfully backfilled asset exif width and height");
} catch (error) {
dPrint(() => "[MIGRATION] Error while backfilling asset exif width and height: $error");
}
}
Future<void> migrateDeviceAssetToSqlite(Isar db, Drift drift) async {
try {
final isarDeviceAssets = await db.deviceAssetEntitys.where().findAll();

View File

@@ -24,6 +24,7 @@ SyncAssetV1 _createAsset({
String ownerId = 'user-1',
int? width,
int? height,
bool isEdited = false,
}) {
return SyncAssetV1(
id: id,
@@ -44,7 +45,7 @@ SyncAssetV1 _createAsset({
livePhotoVideoId: null,
stackId: null,
thumbhash: null,
isEdited: false,
isEdited: isEdited,
);
}
@@ -154,7 +155,7 @@ void main() {
}
});
test('does not update dimensions if asset already has width and height', () async {
test('does not update dimensions if asset is edited', () async {
const assetId = 'asset-with-dimensions';
const existingWidth = 1920;
const existingHeight = 1080;
@@ -169,6 +170,7 @@ void main() {
fileName: 'with_dimensions.jpg',
width: existingWidth,
height: existingHeight,
isEdited: true,
);
await sut.updateAssetsV1([asset]);

View File

@@ -0,0 +1,8 @@
import { Kysely, sql } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
await sql`UPDATE "session" SET "isPendingSyncReset" = false`.execute(db);
await sql`TRUNCATE TABLE "session_sync_checkpoint"`.execute(db);
}
export async function down(): Promise<void> {}