Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Preserve motion detection fallback and reject unset epoch dates

Neeraj Guptafe796af40c86
diff --git a/mobile/apps/photos/lib/db/files_db.dart b/mobile/apps/photos/lib/db/files_db.dart
index f002b56fd4..9c813730cb 100644
--- a/mobile/apps/photos/lib/db/files_db.dart
+++ b/mobile/apps/photos/lib/db/files_db.dart
@@ -1246,7 +1246,8 @@ class FilesDB with SqlDbBase {
heightKey: dimensions.height,
},
mediaTypeKey: ?mediaType,
- motionVideoIndexKey: ?motionVideoIndex,
+ if (mediaType != null || motionVideoIndex != null)
+ motionVideoIndexKey: motionVideoIndex,
}),
processingVersion,
localID,
diff --git a/mobile/apps/photos/lib/module/metadata/local_file.dart b/mobile/apps/photos/lib/module/metadata/local_file.dart
index 88657b961b..224277ce53 100644
--- a/mobile/apps/photos/lib/module/metadata/local_file.dart
+++ b/mobile/apps/photos/lib/module/metadata/local_file.dart
@@ -38,7 +38,7 @@ void applyDisplayDimensions(EnteFile file, int width, int height) {
void applyMediaTypeMetadata(
EnteFile file,
bool isPanorama,
- int motionVideoIndex,
+ int? motionVideoIndex,
) {
file.pubMmdEncodedJson = jsonEncode({
...jsonDecode(file.pubMmdEncodedJson ?? '{}') as Map<String, dynamic>,
diff --git a/mobile/apps/photos/lib/services/sync/offline_import_metadata_service.dart b/mobile/apps/photos/lib/services/sync/offline_import_metadata_service.dart
index 9d3b6a17fc..f023ef554f 100644
--- a/mobile/apps/photos/lib/services/sync/offline_import_metadata_service.dart
+++ b/mobile/apps/photos/lib/services/sync/offline_import_metadata_service.dart
@@ -125,7 +125,7 @@ class OfflineImportMetadataService {
applyMediaTypeMetadata(
file,
metadata.isPanorama,
- metadata.motionVideoStart?.toInt() ?? 0,
+ metadata.motionVideoStart?.toInt(),
);
}
diff --git a/mobile/apps/photos/test/db/offline_metadata_test.dart b/mobile/apps/photos/test/db/offline_metadata_test.dart
index 738a87c5c7..59380637ea 100644
--- a/mobile/apps/photos/test/db/offline_metadata_test.dart
+++ b/mobile/apps/photos/test/db/offline_metadata_test.dart
@@ -73,6 +73,23 @@ void main() {
);
expect(rows.last[FilesDB.columnMetadataVersion], 1);
+ await files.updateOfflineImportMetadataForLocalID(
+ "local",
+ processingVersion: 3,
+ modificationTime: 100,
+ mediaType: 0,
+ );
+ final unknown = await db.getAll(
+ 'SELECT * FROM ${FilesDB.filesTable} WHERE ${FilesDB.columnUploadedFileID} = -1',
+ );
+ for (final row in unknown) {
+ final metadata = jsonDecode(
+ row[FilesDB.columnPubMMdEncodedJson] as String,
+ );
+ expect(metadata.containsKey('mvi'), isFalse);
+ expect(metadata['mediaType'], 0);
+ }
+
final edited = EnteFile()
..localID = "local"
..modificationTime = 200;
diff --git a/mobile/apps/photos/test/module/metadata/photo_test.dart b/mobile/apps/photos/test/module/metadata/photo_test.dart
index 2b39e5c374..4efe53b81a 100644
--- a/mobile/apps/photos/test/module/metadata/photo_test.dart
+++ b/mobile/apps/photos/test/module/metadata/photo_test.dart
@@ -12,9 +12,9 @@ void main() {
applyMediaTypeMetadata(file, true, 1234);
expect(file.pubMagicMetadata!.mediaType, 3);
expect(file.pubMagicMetadata!.mvi, 1234);
- applyMediaTypeMetadata(file, false, 0);
+ applyMediaTypeMetadata(file, false, null);
expect(file.pubMagicMetadata!.mediaType, 2);
- expect(file.pubMagicMetadata!.mvi, 0);
+ expect(file.pubMagicMetadata!.mvi, isNull);
expect(file.pubMagicMetadata!.caption, "Keep me");
});
diff --git a/rust/crates/photos/src/metadata.rs b/rust/crates/photos/src/metadata.rs
index 6bd4c7500d..b2100aaadc 100644
--- a/rust/crates/photos/src/metadata.rs
+++ b/rust/crates/photos/src/metadata.rs
@@ -22,6 +22,7 @@ pub fn read_photo_metadata(path: impl AsRef<Path>) -> Result<PhotoMetadata, Erro
capture_date_time: metadata.capture_date_time_with(|date| {
date.precision == DateTimePrecision::Second
&& date.timestamp_micros != Some(0)
+ && !(date.offset_time.is_none() && date.date_time == "1970-01-01T00:00:00")
&& date.date_time != "4501-01-01T00:00:00"
}),
location: metadata.exif_location().or_else(|| metadata.xmp_location()),
diff --git a/rust/crates/photos/tests/metadata_test.rs b/rust/crates/photos/tests/metadata_test.rs
index 6ebf3e18cf..6565013367 100644
--- a/rust/crates/photos/tests/metadata_test.rs
+++ b/rust/crates/photos/tests/metadata_test.rs
@@ -36,6 +36,8 @@ fn skips_partial_and_sentinel_capture_dates_and_continues_to_fallbacks() {
("2004-06-15", true),
("2004-06-15T12:30Z", true),
("1970-01-01T00:00:00Z", true),
+ ("1970-01-01T00:00:00", true),
+ ("1970-01-01T00:00:01", false),
("1970-01-01T05:30:00+05:30", true),
("4501-01-01T00:00:00.000Z", true),
("4501-01-01T00:00:00+05:30", true),