Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix(preview_video_store): modify file check logic to skip files exceeding size and duration limits

Prateek Sunal331675091a80
diff --git a/mobile/lib/db/files_db.dart b/mobile/lib/db/files_db.dart
index 276ef2bb98..ae702d92b4 100644
--- a/mobile/lib/db/files_db.dart
+++ b/mobile/lib/db/files_db.dart
@@ -1686,7 +1686,7 @@ class FilesDB with SqlDbBase {
AND $columnOwnerID = $userID
AND $columnLocalID IS NOT NULL
AND ($columnFileSize IS NULL OR $columnFileSize <= 524288000)
- AND ($columnDuration IS NULL OR $columnDuration <= 1)
+ AND ($columnDuration IS NULL OR $columnDuration <= 60)
ORDER BY $columnCreationTime DESC
''',
[getInt(fileType), beginDate.microsecondsSinceEpoch],
diff --git a/mobile/lib/services/preview_video_store.dart b/mobile/lib/services/preview_video_store.dart
index 24f812d597..092bec4fd8 100644
--- a/mobile/lib/services/preview_video_store.dart
+++ b/mobile/lib/services/preview_video_store.dart
@@ -657,7 +657,7 @@ class PreviewVideoStore {
final fileSize = enteFile.fileSize;
FFProbeProps? props;
File? file;
- bool result = false;
+ bool skipFile = false;
try {
final isFileUnder10MB = fileSize != null && fileSize <= 10 * 1024 * 1024;
@@ -669,13 +669,32 @@ class PreviewVideoStore {
.firstWhereOrNull((e) => e["type"] == "video");
final codec = videoData["codec_name"]?.toString().toLowerCase();
- result = codec?.contains("h264") ?? false;
+ skipFile = codec?.contains("h264") ?? false;
}
}
+
+ int? size = enteFile.fileSize;
+ int? duration = enteFile.duration;
+
+ if (size == null) {
+ file = await getFile(enteFile, isOrigin: true);
+ size = file?.lengthSync();
+ }
+
+ if (duration == null) {
+ file ??= await getFile(enteFile, isOrigin: true);
+ props = await getVideoPropsAsync(file!);
+ duration = props?.duration?.inSeconds;
+ }
+
+ if ((size == null || duration == null) ||
+ (size <= 500 * 1024 * 1024 && duration <= 60)) {
+ skipFile = true;
+ }
} catch (e, sT) {
_logger.warning("Failed to check props", e, sT);
}
- return (props, result, file);
+ return (props, skipFile, file);
}
// generate stream for all files after cutoff date
@@ -721,6 +740,7 @@ class PreviewVideoStore {
var n = allFiles.length, i = 0;
while (i < n) {
final enteFile = allFiles[i];
+
// elimination case for <=10 MB with H.264
final (_, result, _) = await _checkFileForPreviewCreation(enteFile);
final isFailure =