fix: a transcript rescue never replaces an earlier one

The destination name has one-second granularity and mv overwrites.
Closing, re-hosting and closing the same party name within a second
would lose the first transcript while reporting success. Fall back to
a PID-suffixed name when the destination already exists.
This commit is contained in:
veg 2026-09-21 15:03:34 +00:00
parent 471ee5875c
commit 3fe5615ffe
2 changed files with 21 additions and 1 deletions

View file

@ -34,6 +34,22 @@ teardown() { teardown_party_sandbox; }
grep -q "the night" "$HOME"/party-crashed-*.log
}
@test "a rescue never replaces an earlier transcript of the same second" {
export HOME="$PARTY_TMP/home"
mkdir -p "$HOME" "$PARTY_TMP/bin"
# Freeze the clock so both rescues compute the same destination.
printf '#!/bin/sh\necho 20260101-000000\n' > "$PARTY_TMP/bin/date"
chmod +x "$PARTY_TMP/bin/date"
printf 'earlier\n' > "$HOME/party-crashed-20260101-000000.log"
ensure_party_dir "$USER" crashed
printf 'later\n' > "$PARTY_SOCKET_DIR/party-$USER:crashed.d/log"
PATH="$PARTY_TMP/bin:$PATH" run "$PARTY_BIN" clean
[ "$status" -eq 0 ]
grep -q earlier "$HOME/party-crashed-20260101-000000.log"
grep -lq later "$HOME"/party-crashed-20260101-000000-*.log
}
@test "clean removes a crash-before-bind dir (no sock at all)" {
mkdir "$PARTY_SOCKET_DIR/party-$USER:stillborn.d"
run "$PARTY_BIN" clean