diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-28 09:19:33 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-28 09:19:33 +0300 |
| commit | 86c354932e698d52f23e65a1dafb1b7250f4c1b9 (patch) | |
| tree | 2b67fdfab41fab1036c55e91bd2ddf72c25829dd /src/lib/action.source.sh | |
| parent | 94479238557adcab33a95fefbf752a3742b8a8ba (diff) | |
Centralize DIST_DIR-derived paths via working_dir/exif_cache_dir helpers
The EXIF cache dir ($(dirname "$DIST_DIR")/cache/exif) was recomputed inline,
byte for byte, in both cached_photo_identify_output (read/write) and
clear_exif_cache (--force/--clean removal). The plain parent of DIST_DIR
(dirname "$DIST_DIR") was likewise recomputed in metadata-cache and in
action.source.sh's staging-artifact cleanup.
Extract two helpers computed once from DIST_DIR:
- working_dir() in config.source.sh (next to existing_parent_dir, the other
DIST_DIR-parent resolver): plain `dirname "$DIST_DIR"`.
- exif_cache_dir() in metadata-cache.source.sh (owns the EXIF cache):
`working_dir()/cache/exif`.
Route cached_photo_identify_output, clear_exif_cache, and
clean_generation_staging_artifacts through them so the cache reader and the
cleaner can never drift to different directories. Paths are byte-identical to
the prior inline code (dirname semantics, cache/exif suffix, trailing-slash and
relative/absolute handling all preserved). Stale "recompute the cache dir"
comments removed; helpers document the path once. Add a unit test asserting the
helpers agree and resolve beside dist for several DIST_DIR shapes.
Broader DIST_DIR parameterization of leaf pipeline helpers was intentionally
left out of scope (only the duplicated path computation is centralized here).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'src/lib/action.source.sh')
| -rw-r--r-- | src/lib/action.source.sh | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/action.source.sh b/src/lib/action.source.sh index c667519..a038fa7 100644 --- a/src/lib/action.source.sh +++ b/src/lib/action.source.sh @@ -179,14 +179,15 @@ log_configured_action() { # Safety: callers MUST run validate_clean_dist_dir first so a dangerous DIST_DIR # aborts before any deletion. We only match shuriken's own, basename-specific # staging/backup prefixes (never a loose ".shuriken.*" or arbitrary dotfiles), -# derive the parent exactly as the staging code does (dirname "$DIST_DIR"), and -# use nullglob so a missing match never expands to a literal pattern to rm. +# derive the parent via working_dir() (the shared plain `dirname "$DIST_DIR"`, +# exactly the parent the staging code stages into), and use nullglob so a missing +# match never expands to a literal pattern to rm. clean_generation_staging_artifacts() { local final_base final_parent artifact local -a artifacts=() final_base=$(basename "$DIST_DIR") - final_parent=$(dirname "$DIST_DIR") + final_parent=$(working_dir) # nullglob: a non-matching glob expands to nothing rather than to the # literal pattern, so we never accidentally rm a path called "*". |
