summaryrefslogtreecommitdiff
path: root/src/lib/image.source.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-24 10:45:28 +0300
committerPaul Buetow <paul@buetow.org>2026-06-24 10:45:28 +0300
commit6697431d3855d3030b35c2ce232c9ea0e9282ba7 (patch)
tree8e36cce1db02a40ee0954bd552ed43cb4ff2fe21 /src/lib/image.source.sh
parent6dfc0f1a9521cc4afe4941fc1328eec014b760a7 (diff)
Split album-metadata.source.sh into focused modules (6r0)
album-metadata.source.sh aggregated six unrelated concerns. Move each along its existing seam (pure mechanical move, no logic changes): - EXIF presentation (photo_exif_details_html, tooltip helpers, the _photo_exif_values_to wrapper) stays in album-metadata.source.sh, which is now EXIF-presentation only. - File counting (count_files, count_incoming_images, count_tree_files) -> image.source.sh, which already owns incoming_image_files; count_incoming_images is a direct wrapper of it. - Tarball naming (tarball_name_plan, generated_tarball_name) -> archive.source.sh, which already owns tarball()/resolve_tar_opts. - Generation metadata + JSON (_collect_generation_metadata, _generation_metadata_json, write_generation_metadata) -> new generation-metadata.source.sh. - Dry-run (dry_run, collect_dry_run_*, print_dry_run_plan) -> new dry-run.source.sh. - clear_exif_cache -> metadata-cache.source.sh, next to the cache primitive cached_photo_identify_output. LIB_SOURCES (Justfile + src/shuriken.sh): insert generation-metadata and dry-run right after album-metadata, before album-render/album. They depend on image, archive, template and metadata-cache (all earlier or runtime-only calls), and are consumed by the album coordinator and the dry-run CLI action, which come later. bin/shuriken regenerated via just build. File-header comments updated to reflect the new homes. just test, just shellcheck, just check-generated and git diff --check all pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'src/lib/image.source.sh')
-rw-r--r--src/lib/image.source.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/lib/image.source.sh b/src/lib/image.source.sh
index f7cb715..2581228 100644
--- a/src/lib/image.source.sh
+++ b/src/lib/image.source.sh
@@ -53,6 +53,44 @@ incoming_image_files() {
| sort
}
+# File counters for the source tree and the generated dist. Moved here from
+# album-metadata.source.sh (task 6r0): counting incoming/generated files is part
+# of this module's file-enumeration concern -- count_incoming_images is a direct
+# wrapper of incoming_image_files above, and count_files/count_tree_files are the
+# generic siblings the generation-metadata and dry-run modules use to tally the
+# produced photos, thumbs and HTML pages. Behaviour and signatures are unchanged.
+count_files() {
+ local -r dir="$1"; shift
+ local -r name="${1:-}"; shift || true
+
+ if [ ! -d "$dir" ]; then
+ printf '0\n'
+ return
+ fi
+
+ if [ -n "$name" ]; then
+ find "$dir" -maxdepth 1 -type f -name "$name" | wc -l
+ else
+ find "$dir" -maxdepth 1 -type f | wc -l
+ fi
+}
+
+count_incoming_images() {
+ incoming_image_files | wc -l
+}
+
+count_tree_files() {
+ local -r dir="$1"; shift
+ local -r name="$1"; shift
+
+ if [ ! -d "$dir" ]; then
+ printf '0\n'
+ return
+ fi
+
+ find "$dir" -type f -name "$name" | wc -l
+}
+
warn_unsupported_incoming_files() {
local file