From aab4bff6ff09c4061f2f6734a41ff7536e30bbb9 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Mon, 17 Feb 2025 18:54:20 +0530 Subject: [PATCH 1/3] bump version --- mobile/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml index 2af747b753..8c2d314dd4 100644 --- a/mobile/pubspec.yaml +++ b/mobile/pubspec.yaml @@ -12,7 +12,7 @@ description: ente photos application # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.9.98+998 +version: 0.9.99+999 publish_to: none environment: From 0e157a4e33410f13ecfb9f0006422d696dcf7e88 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Tue, 18 Feb 2025 12:19:16 +0530 Subject: [PATCH 2/3] fix: still check 10mb preview limit --- mobile/lib/services/preview_video_store.dart | 59 +++++++++++++------- 1 file changed, 39 insertions(+), 20 deletions(-) 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 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( From ce5a8f04575c81cfdd61882a1cd1e81cfe032f22 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Tue, 18 Feb 2025 14:09:39 +0530 Subject: [PATCH 3/3] fix: logic for queuing and item removal --- mobile/lib/services/preview_video_store.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mobile/lib/services/preview_video_store.dart b/mobile/lib/services/preview_video_store.dart index bbbb39ed42..e175635676 100644 --- a/mobile/lib/services/preview_video_store.dart +++ b/mobile/lib/services/preview_video_store.dart @@ -596,8 +596,10 @@ class PreviewVideoStore { final codecIsH264 = codec?.contains("h264") ?? false; if (codecIsH264) { - _items.removeWhere((key, value) => value.file == enteFile); - Bus.instance.fire(PreviewUpdatedEvent(_items)); + if (_items.containsKey(enteFile.uploadedFileID!)) { + _items.remove(enteFile.uploadedFileID!); + Bus.instance.fire(PreviewUpdatedEvent(_items)); + } return (props, true); } } @@ -634,6 +636,7 @@ class PreviewVideoStore { final (_, result) = await checkFileForPreviewCreation(enteFile); if (result) { + allFiles.remove(enteFile); continue; }