feat: skip already patched ROMs
if a patch has already been applied it will be skipped.
This commit is contained in:
parent
3f04dcb3bf
commit
32a3826139
@ -55,8 +55,16 @@ fi
|
||||
echo "$([ $DRY_RUN -eq 1 ] && echo '[DRY RUN] ')Processing patches..."
|
||||
echo
|
||||
|
||||
# Initialize counters
|
||||
total_patches=0
|
||||
existing_roms=0
|
||||
new_patches=0
|
||||
failed_patches=0
|
||||
|
||||
# Find all .bps files and extract week numbers
|
||||
while IFS= read -r patch_file; do
|
||||
((total_patches++))
|
||||
|
||||
# Extract week number from filename
|
||||
if [[ $patch_file =~ Week([0-9]+)\.bps$ ]]; then
|
||||
week_num="${BASH_REMATCH[1]}"
|
||||
@ -64,10 +72,18 @@ while IFS= read -r patch_file; do
|
||||
padded_week=$(printf "Week%03d.smc" "$week_num")
|
||||
output_file="$OUTPUT_DIR/$padded_week"
|
||||
|
||||
# Check if ROM already exists
|
||||
if [ -f "$output_file" ]; then
|
||||
echo "Skipping $padded_week (already exists)"
|
||||
((existing_roms++))
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ $DRY_RUN -eq 1 ]; then
|
||||
echo "[DRY RUN] Would patch: $patch_file"
|
||||
echo "[DRY RUN] Would create: $output_file"
|
||||
echo
|
||||
((new_patches++))
|
||||
else
|
||||
echo "Patching: $patch_file -> $padded_week"
|
||||
|
||||
@ -77,15 +93,28 @@ while IFS= read -r patch_file; do
|
||||
# Check if patching was successful
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully created $padded_week"
|
||||
((new_patches++))
|
||||
else
|
||||
echo "Error patching $patch_file"
|
||||
((failed_patches++))
|
||||
fi
|
||||
echo
|
||||
fi
|
||||
else
|
||||
echo "Warning: Could not extract week number from filename: $patch_file"
|
||||
((failed_patches++))
|
||||
fi
|
||||
done < <(find "$PATCHES_DIR" -type f -name "Week*.bps" | sort -V)
|
||||
|
||||
total_files=$(find "$PATCHES_DIR" -type f -name "Week*.bps" | wc -l)
|
||||
echo "$([ $DRY_RUN -eq 1 ] && echo '[DRY RUN] ')Would create $total_files patched ROMs in $OUTPUT_DIR"
|
||||
# Print summary
|
||||
echo
|
||||
echo "$([ $DRY_RUN -eq 1 ] && echo '[DRY RUN] ')Summary:"
|
||||
echo "Total patches found: $total_patches"
|
||||
echo "Already patched ROMs: $existing_roms"
|
||||
echo "New ROMs to create: $new_patches"
|
||||
if [ $failed_patches -gt 0 ]; then
|
||||
echo "Failed patches: $failed_patches"
|
||||
fi
|
||||
echo
|
||||
echo "ROM status in $OUTPUT_DIR:"
|
||||
echo "Total ROMs after operation: $(($existing_roms + $new_patches))"
|
||||
|
Loading…
x
Reference in New Issue
Block a user