only migrate for images

This commit is contained in:
Alex
2026-01-27 22:12:21 -06:00
parent a781c78caf
commit 99a8740f1b
3 changed files with 23 additions and 9 deletions
@@ -98,7 +98,12 @@ class AssetService {
height = fetched?.height?.toDouble();
}
return (width: width, height: height, isFlipped: false);
// Check exif for orientation to determine if dimensions should be flipped
// This is important for videos where raw file dimensions may not match display dimensions
final exif = await _remoteAssetRepository.getExif(asset.id);
final isFlipped = exif?.isFlipped ?? false;
return (width: width, height: height, isFlipped: isFlipped);
}
Future<List<(String, String)>> getPlaces(String userId) {
+9 -7
View File
@@ -284,14 +284,16 @@ Future<void> _syncLocalAlbumIsIosSharedAlbum(Drift db) async {
Future<void> _backfillAssetExifWidthHeight(Drift db) async {
try {
// Only backfill width/height when exif values are NULL or 0
// Don't overwrite existing valid exif dimensions (especially important for videos)
// Only backfill images (type = 1), not videos
// Videos have different dimension handling based on orientation/exif
await db.customStatement('''
UPDATE remote_exif_entity
SET width = (SELECT width FROM remote_asset_entity WHERE id = remote_exif_entity.asset_id),
height = (SELECT height FROM remote_asset_entity WHERE id = remote_exif_entity.asset_id)
WHERE (width IS NULL OR width = 0 OR height IS NULL OR height = 0)
AND EXISTS (SELECT 1 FROM remote_asset_entity WHERE id = remote_exif_entity.asset_id);
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
AND asset.type = 1
AND (remote_exif.width IS NULL OR remote_exif.width = 0 OR remote_exif.height IS NULL OR remote_exif.height = 0);
''');
dPrint(() => "[MIGRATION] Successfully backfilled asset exif width and height");
+8 -1
View File
@@ -118,7 +118,13 @@ abstract final class TestUtils {
return result;
}
static domain.RemoteAsset createRemoteAsset({required String id, int? width, int? height, String? ownerId}) {
static domain.RemoteAsset createRemoteAsset({
required String id,
int? width,
int? height,
String? ownerId,
String? localId,
}) {
return domain.RemoteAsset(
id: id,
checksum: 'checksum1',
@@ -132,6 +138,7 @@ abstract final class TestUtils {
width: width,
height: height,
isEdited: false,
localId: localId,
);
}