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"