feat: US-002 - Guard against data loss in archive.sh

This commit is contained in:
2026-03-27 18:40:31 -04:00
parent a935997ac4
commit 3c518794ee

View File

@@ -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"