From 94af48a97f71f1b9ce92469b7899a9ffc9138a9d Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Tue, 18 Apr 2023 19:40:16 +0200 Subject: [PATCH] minor --- .../entry/extensions/metadata_edition.dart | 2 +- lib/model/entry/extensions/props.dart | 2 ++ .../metadata/metadata_edit_service.dart | 2 +- .../metadata/metadata_fetch_service.dart | 22 +++++++++---------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/model/entry/extensions/metadata_edition.dart b/lib/model/entry/extensions/metadata_edition.dart index ea4973ee1..9d1f2f7c3 100644 --- a/lib/model/entry/extensions/metadata_edition.dart +++ b/lib/model/entry/extensions/metadata_edition.dart @@ -27,7 +27,7 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry { final appliedModifier = await _applyDateModifierToEntry(userModifier); if (appliedModifier == null) { - if (!isMissingAtPath && userModifier.action != DateEditAction.copyField) { + if (isValid && userModifier.action != DateEditAction.copyField) { await reportService.recordError('failed to get date for modifier=$userModifier, entry=$this', null); } return {}; diff --git a/lib/model/entry/extensions/props.dart b/lib/model/entry/extensions/props.dart index 5bd21349b..f5d064c2f 100644 --- a/lib/model/entry/extensions/props.dart +++ b/lib/model/entry/extensions/props.dart @@ -12,6 +12,8 @@ import 'package:aves/theme/text.dart'; import 'package:aves/utils/android_file_utils.dart'; extension ExtraAvesEntryProps on AvesEntry { + bool get isValid => !isMissingAtPath && sizeBytes != 0 && width > 0 && height > 0; + // type String get mimeTypeAnySubtype => mimeType.replaceAll(RegExp('/.*'), '/*'); diff --git a/lib/services/metadata/metadata_edit_service.dart b/lib/services/metadata/metadata_edit_service.dart index d5839a0fe..ec3d48bac 100644 --- a/lib/services/metadata/metadata_edit_service.dart +++ b/lib/services/metadata/metadata_edit_service.dart @@ -123,7 +123,7 @@ class PlatformMetadataEditService implements MetadataEditService { } Future _processPlatformException(AvesEntry entry, PlatformException e, StackTrace stack) async { - if (!entry.isMissingAtPath) { + if (entry.isValid) { final code = e.code; if (code.endsWith('mp4largemoov')) { await reportService.recordError(_Mp4LargeMoovException(code: e.code, message: e.message, details: e.details, stacktrace: e.stacktrace), stack); diff --git a/lib/services/metadata/metadata_fetch_service.dart b/lib/services/metadata/metadata_fetch_service.dart index d6e618a7b..bbd5d7b30 100644 --- a/lib/services/metadata/metadata_fetch_service.dart +++ b/lib/services/metadata/metadata_fetch_service.dart @@ -58,7 +58,7 @@ class PlatformMetadataFetchService implements MetadataFetchService { }); if (result != null) return result as Map; } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { + if (entry.isValid) { await reportService.recordError(e, stack); } } @@ -96,7 +96,7 @@ class PlatformMetadataFetchService implements MetadataFetchService { result['id'] = entry.id; return CatalogMetadata.fromMap(result); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { + if (entry.isValid) { await reportService.recordError(e, stack); } } @@ -124,7 +124,7 @@ class PlatformMetadataFetchService implements MetadataFetchService { }) as Map; return OverlayMetadata.fromMap(result); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { + if (entry.isValid) { await reportService.recordError(e, stack); } } @@ -141,7 +141,7 @@ class PlatformMetadataFetchService implements MetadataFetchService { }) as Map; return GeoTiffInfo.fromMap(result); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { + if (entry.isValid) { await reportService.recordError(e, stack); } } @@ -166,7 +166,7 @@ class PlatformMetadataFetchService implements MetadataFetchService { } return MultiPageInfo.fromPageMaps(entry, pageMaps); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { + if (entry.isValid) { await reportService.recordError(e, stack); } } @@ -186,7 +186,7 @@ class PlatformMetadataFetchService implements MetadataFetchService { }) as Map; return PanoramaInfo.fromMap(result); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { + if (entry.isValid) { await reportService.recordError(e, stack); } } @@ -202,7 +202,7 @@ class PlatformMetadataFetchService implements MetadataFetchService { }); if (result != null) return (result as List).cast().map((fields) => fields.cast()).toList(); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { + if (entry.isValid) { await reportService.recordError(e, stack); } } @@ -219,7 +219,7 @@ class PlatformMetadataFetchService implements MetadataFetchService { }); if (result != null) return AvesXmp.fromList((result as List).cast()); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { + if (entry.isValid) { await reportService.recordError(e, stack); } } @@ -254,7 +254,7 @@ class PlatformMetadataFetchService implements MetadataFetchService { 'prop': prop, }); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { + if (entry.isValid) { await reportService.recordError(e, stack); } } @@ -274,7 +274,7 @@ class PlatformMetadataFetchService implements MetadataFetchService { return dateTimeFromMillis(result, isUtc: false); } } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { + if (entry.isValid) { await reportService.recordError(e, stack); } } @@ -290,7 +290,7 @@ class PlatformMetadataFetchService implements MetadataFetchService { 'sizeBytes': entry.sizeBytes, }); } on PlatformException catch (e, stack) { - if (!entry.isMissingAtPath) { + if (entry.isValid) { await reportService.recordError(e, stack); } }