From 6dfc0f1a9521cc4afe4941fc1328eec014b760a7 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 24 Jun 2026 10:36:25 +0300 Subject: Promote single canonical identify-stream EXIF parser into metadata-cache (8r0) The `identify -verbose` EXIF-line regex and its array-fill loop were duplicated in three places that had already drifted: album-metadata's photo_exif_details_html and _photo_exif_values_to (exif: only) and stats-aggregate's _stats_parse_identify_stream (exif: plus a native Geometry -> __geometry path). Promote one canonical parser, photo_exif_values_to, into metadata-cache.source.sh next to its sibling cache primitive cached_photo_identify_output. It reads an identify stream from stdin and fills a nameref associative array; it is a strict superset of all three former sites (bare exif: tag keys plus the synthetic __geometry key). - stats accumulate_photo_stats now calls photo_exif_values_to (stdin); _stats_parse_identify_stream is removed. - album _photo_exif_values_to is a thin wrapper that pipes cached_photo_identify_output through the canonical parser. - album photo_exif_details_html consumes the same parser and skips the __geometry key it does not display. metadata-cache is sourced before both consumers in LIB_SOURCES, so the canonical parser is available at use time. Regenerated bin/shuriken via `just build`. Added test_shared_identify_parser_returns_exif_and_geometry asserting one parse yields both an exif: key and __geometry. Co-Authored-By: Claude Opus 4.8 --- tests/cli.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests') diff --git a/tests/cli.sh b/tests/cli.sh index 320ab7e..eae2f19 100755 --- a/tests/cli.sh +++ b/tests/cli.sh @@ -6151,6 +6151,35 @@ test_stats_tolerates_missing_and_edge_case_fields() { test::teardown } +# Regression for 8r0: the single canonical parser (photo_exif_values_to in +# metadata-cache.source.sh, now shared by album-metadata and stats-aggregate) +# must be a strict superset of the three former copies -- it returns both the +# bare exif: tag keys the album relies on AND the synthetic __geometry key the +# stats dimensions recorder relies on, from one parse of one stdin stream. +test_shared_identify_parser_returns_exif_and_geometry() { + local fixture + local -A values=() + + test::setup + test::source_shuriken_lib + + fixture=$' Geometry: 160x90+0+0\n' + fixture+=$' exif:Make: Canon\n' + fixture+=$' exif:FNumber: 28/10' + + photo_exif_values_to values <<< "$fixture" + + # exif: tags are keyed WITHOUT the "exif:" prefix (album/stats convention). + test "${values[Make]}" = 'Canon' + test "${values[FNumber]}" = '28/10' + # The native Geometry line is captured under the synthetic __geometry key. + test "${values[__geometry]}" = '160x90+0+0' + # Exactly the three recognised fields, nothing spurious. + test "${#values[@]}" -eq 3 + + test::teardown +} + test_stats_distinct_cameras_get_unique_slugs() { local sep test::setup @@ -6768,6 +6797,9 @@ main() { test::run_case \ 'stats tolerate missing and edge-case fields' \ test_stats_tolerates_missing_and_edge_case_fields + test::run_case \ + 'shared identify parser returns exif and geometry' \ + test_shared_identify_parser_returns_exif_and_geometry test::run_case \ 'stats give distinct cameras unique slugs' \ test_stats_distinct_cameras_get_unique_slugs -- cgit v1.2.3