fix/empty-raw #7

Merged
ludovic.terrier merged 12 commits from fix/empty-raw into master 2026-11-11 11:09:25 +01:00
Owner
No description provided.
empty.sh had no tests and a hardcoded library root, so nothing could
run it safely. EMPTY_ROOT overrides the root; an empty value aborts
instead of falling back to prod, so a bad env cannot reach the real
library.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The listing excluded _raw but the delete step did not, so confirming
the prompt removed the _raw dirs photostruct.sh creates on purpose.
Both steps now call one find_empty_directories rule so they cannot
drift apart again.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Thumbs.db was listed and the prompt offered to delete it, but the
delete step never removed it. Handle it the same way as .DS_Store.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
With an all-empty library, find listed the root itself and the delete
step removed /photos/external, which is a mount point. -mindepth 1
excludes it. Tests also pin the intended cascade: -delete implies
-depth, so an empty chain a/b/c is removed whole.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A directory holding only Thumbs.db or .DS_Store was not empty when
the dir step ran, so it needed a second run. Delete junk first, and
always run the dir step after it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Silences shellcheck SC2162; backslashes in the answer are no longer
mangled.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The listing is computed before junk removal, so folders left empty
once their junk is gone, and parents emptied by the cascade, are
deleted without being listed. The prompt now says so, so the user
confirms with the full scope in view. Deletion logic is unchanged.

The prompt is printed with printf to stderr instead of read -p, which
only shows it on a tty; this is what lets the test see the text.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Only "no" was tested as a refusal; an empty answer, y, YES and EOF
must also delete nothing, since only exact "yes" confirms. The
nothing-listed run is checked to leave the tree untouched. errexit in
the test file makes a failed fixture setup abort instead of passing
vacuously, and an unused assignment is gone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Comments like "Function to delete ..." repeat the function name.
Keep only the why comments, and make the header say the script also
deletes after confirmation.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
On EOF, read failed under errexit and the script died silently with
the prompt line left open. End the line, say it cancelled, and keep
exit 1 so callers still see the answer was missing. Nothing is deleted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Refusals were only checked by tree snapshot, so a non-zero exit on
cancel would pass unnoticed; assert status 0. Assert the prompt goes
to stderr and not stdout, since scripts may parse stdout. Drop
comments on new_lib and run that restated the code.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The prompt is on stderr, but the newline that closes it on EOF went to
stdout, so a caller capturing stdout got a stray blank line and the
terminal kept the prompt unterminated. The tests now pin the EOF
streams, and the declined run's status, which under errexit would
otherwise abort the suite without a FAIL line.

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!7
No description provided.