π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Simplify check for checking preview req
Neeraj Gupta09ff43a1efd3
diff --git a/mobile/lib/models/metadata/file_magic.dart b/mobile/lib/models/metadata/file_magic.dartindex 02f6188a9d..53627aafbc 100644--- a/mobile/lib/models/metadata/file_magic.dart+++ b/mobile/lib/models/metadata/file_magic.dart@@ -9,6 +9,7 @@ const captionKey = "caption";const uploaderNameKey = "uploaderName";const widthKey = 'w';const heightKey = 'h';+const streamVersionKey = 'sv';const mediaTypeKey = 'mediaType';const latKey = "lat";const longKey = "long";@@ -48,6 +49,10 @@ class PubMagicMetadata {double? lat;double? long;+ // Indicates streaming version of the file.+ // If this is set, then the file is a streaming version of the original file.+ int? sv;+// ISO 8601 datetime without timezone. This contains the date and time of the photo in the original tz// where the photo was taken.String? dateTime;@@ -83,6 +88,7 @@ class PubMagicMetadata {this.mediaType,this.dateTime,this.offsetTime,+ this.sv,});factory PubMagicMetadata.fromEncodedJson(String encodedJson) =>@@ -107,6 +113,7 @@ class PubMagicMetadata {mediaType: map[mediaTypeKey],dateTime: map[dateTimeKey],offsetTime: map[offsetTimeKey],+ sv: safeParseInt(map[streamVersionKey], streamVersionKey),);}diff --git a/mobile/lib/services/preview_video_store.dart b/mobile/lib/services/preview_video_store.dartindex ce6178065e..a240471fb3 100644--- a/mobile/lib/services/preview_video_store.dart+++ b/mobile/lib/services/preview_video_store.dart@@ -132,7 +132,6 @@ class PreviewVideoStore {removeFile = true;return;}-try {// check if playlist already existif (await getPlaylist(enteFile) != null) {@@ -151,7 +150,6 @@ class PreviewVideoStore {return;}}-// elimination case for <=10 MB with H.264var (props, result, file) = await _checkFileForPreviewCreation(enteFile);if (result) {@@ -684,20 +682,37 @@ class PreviewVideoStore {Future<(FFProbeProps?, bool, File?)> _checkFileForPreviewCreation(EnteFile enteFile,) async {- final fileSize = enteFile.fileSize;+ if ((enteFile.pubMagicMetadata?.sv ?? 0) == 1) {+ _logger.info(+ "Skip Preview due to sv=1 for ${enteFile.displayName}",+ );+ return (null, true, null);+ }+ if (enteFile.fileSize == null || enteFile.duration == null) {+ _logger.warning(+ "Skip Preview due to misisng size/duration for ${enteFile.displayName}",+ );+ return (null, true, null);+ }+ final int size = enteFile.fileSize!;+ final int duration = enteFile.duration!;+ if (size >= 500 * 1024 * 1024 || duration > 60) {+ _logger.info(+ "Skip Preview due to size: $size or duration: $duration",+ );+ return (null, true, null);+ }FFProbeProps? props;File? file;bool skipFile = false;-try {- final isFileUnder10MB = fileSize != null && fileSize <= 10 * 1024 * 1024;+ final isFileUnder10MB = size <= 10 * 1024 * 1024;if (isFileUnder10MB) {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();skipFile = codec?.contains("h264") ?? false;@@ -709,28 +724,6 @@ class PreviewVideoStore {}}}-- 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;- _logger.info(- "[init] Ignoring file ${enteFile.displayName} for preview due to size: $size and duration: $duration",- );- }} catch (e, sT) {_logger.warning("Failed to check props", e, sT);}