refactor/photorenamer-outcome #9

Merged
ludovic.terrier merged 3 commits from refactor/photorenamer-outcome into master 2026-11-11 23:08:28 +01:00
Owner
No description provided.
The suite checks process_file only through log text and file state. These
cases call it directly and name its outcome: renamed, each skip kind,
ignored, unreadable and failed, sidecar refusals included. They run under
the errexit, nounset and pipefail options that main sets, so a sourced call
behaves as in production.

process_file has no outcome interface yet, so the harness reads it from the
counter deltas. The next commit swaps that for the real interface and keeps
every assertion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
process_file reported only through the global counters, so each failure
site repeated a log call, a counter bump and a return, and a caller could
not tell what happened to a file without reading the log.

process_file now sets OUTCOME to ignored, skipped, renamed, failed or
unreadable, and still returns 0. A non-zero return would trip errexit in
main, and "process_file || rc=$?" would turn errexit off inside it. Output
on stdout would need a subshell, which would lose the Live Photo pairs.
unreadable stays apart from failed because a file whose metadata cannot be
read counts as failed but not as analyzed.

fail_file is the one place that logs a failure and sets its outcome.
count_outcome in main maps outcomes to the same counters as before, so the
summary and the exit code do not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
process_file created ERRFILE and record_pair created PAIRFILE on first
use, but only main set the trap that removes them. A sourced call to
process_file left both files behind.

main now creates ERRFILE and PAIRFILE next to LIST, under the same trap.
A direct call to process_file without an ERRFILE gets one for that call
and removes it; a caller under errexit passes its own, since an abort
skips the removal. If that temp file cannot be made, the file is
unreadable: it was never read, so it is not counted as analyzed. A direct
caller that wants Live Photo pairs across calls passes its own PAIRFILE,
as main does; otherwise none is recorded, so nothing leaks. PAIRFILE now
always exists, so paired_stem checks it is not empty with [ -s ], which
skips four awk runs for each MOV when there are no pairs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ludovic.terrier/scripts!9
No description provided.