During compression checks, only look for files in folders that exist

This commit is contained in:
icenine451 2025-03-19 14:21:09 -04:00
parent 2c296b6fdb
commit d423ed7fe7

View file

@ -163,57 +163,61 @@ find_compatible_games() {
while IFS= read -r system; do while IFS= read -r system; do
log d "Checking system: $system" log d "Checking system: $system"
local compression_candidates if [[ -d "$roms_folder/$system" ]]; then
compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt") local compression_candidates
if [[ -n "$compression_candidates" ]]; then compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt")
while IFS= read -r game; do if [[ -n "$compression_candidates" ]]; then
log d "Checking game: $game" while IFS= read -r game; do
local compatible_compression_format log d "Checking game: $game"
compatible_compression_format=$(find_compatible_compression_format "$game") local compatible_compression_format
local file_ext="${game##*.}" compatible_compression_format=$(find_compatible_compression_format "$game")
case "$compression_format" in local file_ext="${game##*.}"
"chd") case "$compression_format" in
if [[ "$compatible_compression_format" == "chd" ]]; then "chd")
if [[ "$file_ext" == "chd" ]]; then if [[ "$compatible_compression_format" == "chd" ]]; then
log d "Skipping $game because it is already a CHD file." if [[ "$file_ext" == "chd" ]]; then
elif [[ ! -f "${game%.*}.chd" ]]; then log d "Skipping $game because it is already a CHD file."
log d "Game $game is compatible with CHD compression" elif [[ ! -f "${game%.*}.chd" ]]; then
echo "${game}^chd" >> "$output_file" log d "Game $game is compatible with CHD compression"
echo "${game}^chd" >> "$output_file"
fi
fi fi
fi ;;
;; "zip")
"zip") if [[ "$compatible_compression_format" == "zip" ]]; then
if [[ "$compatible_compression_format" == "zip" ]]; then if [[ "$file_ext" == "zip" ]]; then
if [[ "$file_ext" == "zip" ]]; then log d "Skipping $game because it is already a ZIP file."
log d "Skipping $game because it is already a ZIP file." elif [[ ! -f "${game%.*}.zip" ]]; then
elif [[ ! -f "${game%.*}.zip" ]]; then log d "Game $game is compatible with ZIP compression"
log d "Game $game is compatible with ZIP compression" echo "${game}^zip" >> "$output_file"
echo "${game}^zip" >> "$output_file" fi
fi fi
fi ;;
;; "rvz")
"rvz") if [[ "$compatible_compression_format" == "rvz" ]]; then
if [[ "$compatible_compression_format" == "rvz" ]]; then if [[ "$file_ext" == "rvz" ]]; then
if [[ "$file_ext" == "rvz" ]]; then log d "Skipping $game because it is already an RVZ file."
log d "Skipping $game because it is already an RVZ file." elif [[ ! -f "${game%.*}.rvz" ]]; then
elif [[ ! -f "${game%.*}.rvz" ]]; then log d "Game $game is compatible with RVZ compression"
log d "Game $game is compatible with RVZ compression" echo "${game}^rvz" >> "$output_file"
echo "${game}^rvz" >> "$output_file" fi
fi fi
fi ;;
;; "all")
"all") if [[ "$compatible_compression_format" != "none" ]]; then
if [[ "$compatible_compression_format" != "none" ]]; then if [[ "$file_ext" == "$compatible_compression_format" ]]; then
if [[ "$file_ext" == "$compatible_compression_format" ]]; then log d "Skipping $game because it is already in $compatible_compression_format format."
log d "Skipping $game because it is already in $compatible_compression_format format." else
else log d "Game $game is compatible with $compatible_compression_format compression"
log d "Game $game is compatible with $compatible_compression_format compression" echo "${game}^${compatible_compression_format}" >> "$output_file"
echo "${game}^${compatible_compression_format}" >> "$output_file" fi
fi fi
fi ;;
;; esac
esac done < <(printf '%s\n' "$compression_candidates")
done < <(printf '%s\n' "$compression_candidates") fi
else
log i "Rom folder for $system is missing, skipping"
fi fi
done < <(printf '%s\n' "$compressable_systems_list") done < <(printf '%s\n' "$compressable_systems_list")