From 3c518794eec05b53fbd00697e3eba59938236b5e Mon Sep 17 00:00:00 2001 From: Sheldon Finlay Date: Fri, 27 Mar 2026 18:40:31 -0400 Subject: [PATCH] feat: US-002 - Guard against data loss in archive.sh --- lib/archive.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/archive.sh b/lib/archive.sh index 02e522e..d67d123 100644 --- a/lib/archive.sh +++ b/lib/archive.sh @@ -75,6 +75,12 @@ archive_run() { [ -d "$LOOP_DIR/contracts" ] && cp -r "$LOOP_DIR/contracts" "$archive_dir/" fi + # Verify the archive received content before deleting originals + if ! find "$archive_dir" -maxdepth 1 -type f | read -r; then + log "WARNING: Archive directory $archive_dir is empty after copy — skipping deletion of originals to prevent data loss" + return + fi + # Clean up old run's artifacts (progress.md, contracts — NOT prd.json which belongs to new feature) rm -f "$LOOP_DIR/progress.md" rm -rf "$LOOP_DIR/contracts"