From 8517430a1b48b3570e0383409dc5c28fa61f8797 Mon Sep 17 00:00:00 2001 From: Martin Kampas Date: Fri, 1 Mar 2024 22:41:29 +0100 Subject: [PATCH] Deal with rating missing in XMP sidecars Avoid getting Rating of 0 when rating metadata is not included in a sidecar. --- src/backend/model/fileaccess/MetadataLoader.ts | 10 ++++++++-- test/backend/assets/sidecar/metadata_v2.json | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/backend/model/fileaccess/MetadataLoader.ts b/src/backend/model/fileaccess/MetadataLoader.ts index d597b6d4..e0fcb50f 100644 --- a/src/backend/model/fileaccess/MetadataLoader.ts +++ b/src/backend/model/fileaccess/MetadataLoader.ts @@ -175,7 +175,10 @@ export class MetadataLoader { delete (sidecarData as any)['xap']; } if ((sidecarData as SideCar).xmp !== undefined) { - if ((sidecarData as SideCar).xmp.Rating !== undefined) { + if ( + (sidecarData as SideCar).xmp.Rating !== undefined && + (sidecarData as SideCar).xmp.Rating > 0 + ) { metadata.rating = (sidecarData as SideCar).xmp.Rating; } if ( @@ -651,7 +654,10 @@ export class MetadataLoader { delete (sidecarData as any)['xap']; } if ((sidecarData as SideCar).xmp !== undefined) { - if ((sidecarData as SideCar).xmp.Rating !== undefined) { + if ( + (sidecarData as SideCar).xmp.Rating !== undefined && + (sidecarData as SideCar).xmp.Rating > 0 + ) { metadata.rating = (sidecarData as SideCar).xmp.Rating; } if ( diff --git a/test/backend/assets/sidecar/metadata_v2.json b/test/backend/assets/sidecar/metadata_v2.json index e66ce699..36a37353 100644 --- a/test/backend/assets/sidecar/metadata_v2.json +++ b/test/backend/assets/sidecar/metadata_v2.json @@ -10,6 +10,5 @@ "book", "first", "second" - ], - "rating": 0 + ] }