Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix: still check 10mb preview limit

Prateek Sunal0e157a4e3341
diff --git a/mobile/lib/services/preview_video_store.dart b/mobile/lib/services/preview_video_store.dart
index 97145056e1..bbbb39ed42 100644
--- a/mobile/lib/services/preview_video_store.dart
+++ b/mobile/lib/services/preview_video_store.dart
@@ -135,7 +135,15 @@ class PreviewVideoStore {
}
}
+ var (props, result) = await checkFileForPreviewCreation(enteFile);
+
+ if (result) {
+ return;
+ }
+
if (uploadingFileId >= 0) {
+ if (uploadingFileId == enteFile.uploadedFileID) return;
+
_items[enteFile.uploadedFileID!] = PreviewItem(
status: PreviewItemStatus.inQueue,
file: enteFile,
@@ -158,7 +166,7 @@ class PreviewVideoStore {
);
Bus.instance.fire(PreviewUpdatedEvent(_items));
- final props = await getVideoPropsAsync(file);
+ props = await getVideoPropsAsync(file);
final fileSize = enteFile.fileSize ?? file.lengthSync();
final videoData = List.from(props?.propData?["streams"] ?? [])
@@ -571,6 +579,32 @@ class PreviewVideoStore {
}
}
+ Future<(FFProbeProps?, bool)> checkFileForPreviewCreation(
+ EnteFile enteFile,
+ ) async {
+ final fileSize = enteFile.fileSize;
+ FFProbeProps? props;
+
+ if (fileSize != null && fileSize <= 10 * 1024 * 1024) {
+ final file = await getFile(enteFile, isOrigin: true);
+ if (file != null) {
+ props = await getVideoPropsAsync(file);
+ final videoData = List.from(props?.propData?["streams"] ?? [])
+ .firstWhereOrNull((e) => e["type"] == "video");
+
+ final codec = videoData["codec_name"]?.toString().toLowerCase();
+ final codecIsH264 = codec?.contains("h264") ?? false;
+
+ if (codecIsH264) {
+ _items.removeWhere((key, value) => value.file == enteFile);
+ Bus.instance.fire(PreviewUpdatedEvent(_items));
+ return (props, true);
+ }
+ }
+ }
+ return (props, false);
+ }
+
// get all files after cutoff date and add it to queue for preview creation
// only run when video streaming is enabled
Future<void> putFilesForPreviewCreation() async {
@@ -597,25 +631,10 @@ class PreviewVideoStore {
// set all video status to be in queue
for (final enteFile in allFiles) {
- final fileSize = enteFile.fileSize;
- FFProbeProps? props;
-
- if (fileSize != null && fileSize <= 10 * 1024 * 1024) {
- final file = await getFile(enteFile, isOrigin: true);
- if (file != null) {
- props = await getVideoPropsAsync(file);
- final videoData = List.from(props?.propData?["streams"] ?? [])
- .firstWhereOrNull((e) => e["type"] == "video");
-
- final codec = videoData["codec_name"]?.toString().toLowerCase();
- final codecIsH264 = codec?.contains("h264") ?? false;
-
- if (codecIsH264) {
- _items.removeWhere((key, value) => value.file == enteFile);
- Bus.instance.fire(PreviewUpdatedEvent(_items));
- continue;
- }
- }
+ final (_, result) = await checkFileForPreviewCreation(enteFile);
+
+ if (result) {
+ continue;
}
_items[enteFile.uploadedFileID!] = PreviewItem(