Skip to content

armgit / ente

Public Imported from GitHub
0

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

Simplify

laurenspriem198350baf5e5
diff --git a/mobile/apps/photos/lib/utils/ml_util.dart b/mobile/apps/photos/lib/utils/ml_util.dart
index aaf257b34a..a32a789fbf 100644
--- a/mobile/apps/photos/lib/utils/ml_util.dart
+++ b/mobile/apps/photos/lib/utils/ml_util.dart
@@ -961,20 +961,6 @@ Future<MLResult> analyzeImageRust(Map args) async {
try {
fallback = await _createJpegDecodeFallbackFile(imagePath: imagePath);
} catch (fallbackError, fallbackStack) {
- if (_shouldStoreEmptyResultForRustDecodeFailure(
- primaryError: e,
- fallbackError: fallbackError,
- )) {
- _logger.warning(
- "JPEG fallback conversion failed for fileID $enteFileID (format: $fileFormat); storing empty result instead",
- );
- throw _asInvalidImageFormatExceptionForRustDecodeFailure(
- enteFileID: enteFileID,
- fileFormat: fileFormat,
- primaryError: e,
- fallbackError: fallbackError,
- );
- }
_logger.severe(
"JPEG fallback conversion threw for fileID $enteFileID (format: $fileFormat)",
fallbackError,
@@ -999,20 +985,6 @@ Future<MLResult> analyzeImageRust(Map args) async {
"Rust decode fallback succeeded for fileID $enteFileID (original format: $fileFormat)",
);
} catch (retryError, retryStack) {
- if (_shouldStoreEmptyResultForRustDecodeFailure(
- primaryError: e,
- fallbackError: retryError,
- )) {
- _logger.warning(
- "Rust decode fallback retry failed for fileID $enteFileID (format: $fileFormat); storing empty result instead",
- );
- throw _asInvalidImageFormatExceptionForRustDecodeFailure(
- enteFileID: enteFileID,
- fileFormat: fileFormat,
- primaryError: e,
- fallbackError: retryError,
- );
- }
_logger.severe(
"Rust decode fallback retry failed for fileID $enteFileID (original format: $fileFormat)",
retryError,
@@ -1156,78 +1128,7 @@ String formatExpectedMlSkipReasonForLogs(Object error) {
}
bool _isRustDecodeIssue(Object error) {
- if (error is rust_ml.RustMlError_Decode) {
- return true;
- }
- final message = error.toString().toLowerCase();
- return message.contains("decode error");
-}
-
-bool _shouldStoreEmptyResultForRustDecodeFailure({
- required Object primaryError,
- Object? fallbackError,
-}) {
- if (fallbackError == null) {
- return false;
- }
-
- if (_isInfrastructureFallbackFailure(fallbackError)) {
- return false;
- }
-
- if (_isFileSpecificDecodeFailure(fallbackError)) {
- return true;
- }
- return false;
-}
-
-bool _isFileSpecificDecodeFailure(Object error) {
- final message = _normalizedErrorMessage(error);
- if (_isInfrastructureFallbackFailure(error)) {
- return false;
- }
-
- const fileIssueMarkers = <String>[
- "failed to decode",
- "failed to guess image format",
- "format error",
- "required tag",
- "unsupported image format",
- "unsupported tiff pixel format",
- "invalid image",
- "invalid data",
- "not an image",
- "cannot decode",
- "could not decode",
- "corrupt",
- "corrupted",
- "buffer length does not match dimensions",
- ];
- return fileIssueMarkers.any(message.contains);
-}
-
-bool _isInfrastructureFallbackFailure(Object error) {
- final message = _normalizedErrorMessage(error);
-
- const infrastructureMarkers = <String>[
- "failed to open image file",
- "no such file or directory",
- "permission denied",
- "operation not permitted",
- "read-only file system",
- "file system",
- "filesystem",
- "space left on device",
- "channel-error",
- "missingplugin",
- "unable to establish connection on channel",
- "platformexception(channel-error",
- "out of memory",
- "outofmemory",
- "timed out",
- "timeout",
- ];
- return infrastructureMarkers.any(message.contains);
+ return error is rust_ml.RustMlError_Decode;
}
String _normalizedErrorMessage(Object error) {