mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-28 16:45:42 +00:00
Move post-compression file cleanup to compress_game function to avoid repetition
This commit is contained in:
parent
38d86581e4
commit
2afcf2ead4
|
@ -26,6 +26,29 @@ compress_game() {
|
|||
elif [[ "$1" == "rvz" ]]; then
|
||||
dolphin-tool convert -f rvz -b 131072 -c zstd -l 5 -i "$source_file" -o "$dest_file.rvz"
|
||||
fi
|
||||
|
||||
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
|
||||
if [[ -f "${file%.*}.$compatible_compression_format" ]]; then
|
||||
log i "Performing post-compression file cleanup"
|
||||
if [[ "$file" == *".cue" ]]; then
|
||||
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
||||
local file_path=$(dirname "$(realpath "$file")")
|
||||
while IFS= read -r line
|
||||
do
|
||||
log i "Removing file $file_path/$line"
|
||||
rm -f "$file_path/$line"
|
||||
done < <(printf '%s\n' "$cue_bin_files")
|
||||
log i "Removing file $(realpath $file)"
|
||||
rm -f $(realpath "$file")
|
||||
else
|
||||
log i "Removing file $(realpath $file)"
|
||||
rm -f "$(realpath "$file")"
|
||||
fi
|
||||
else
|
||||
log i "Compressed file ${file%.*}.$compatible_compression_format not found, skipping original file deletion"
|
||||
configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "A compressed version of the file was not found, skipping deletion."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
find_compatible_compression_format() {
|
||||
|
|
|
@ -794,28 +794,6 @@ configurator_compress_single_game_dialog() {
|
|||
echo "# Compressing $(basename "$file") to $compatible_compression_format format" # This updates the Zenity dialog
|
||||
log i "Compressing $(basename "$file") to $compatible_compression_format format"
|
||||
compress_game "$compatible_compression_format" "$file" "$system"
|
||||
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
|
||||
if [[ -f "${file%.*}.$compatible_compression_format" ]]; then
|
||||
log i "Performing post-compression file cleanup"
|
||||
if [[ "$file" == *".cue" ]]; then
|
||||
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
||||
local file_path=$(dirname "$(realpath "$file")")
|
||||
while IFS= read -r line
|
||||
do
|
||||
log i "Removing file $file_path/$line"
|
||||
rm -f "$file_path/$line"
|
||||
done < <(printf '%s\n' "$cue_bin_files")
|
||||
log i "Removing file $(realpath $file)"
|
||||
rm -f $(realpath "$file")
|
||||
else
|
||||
log i "Removing file $(realpath $file)"
|
||||
rm -f "$(realpath "$file")"
|
||||
fi
|
||||
else
|
||||
log i "Compressed file ${file%.*}.$compatible_compression_format not found, skipping original file deletion"
|
||||
configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "A compressed version of the file was not found, skipping deletion."
|
||||
fi
|
||||
fi
|
||||
) |
|
||||
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
|
@ -922,27 +900,6 @@ configurator_compress_multiple_games_dialog() {
|
|||
games_left_to_compress=$((games_left_to_compress-1))
|
||||
log i "Games left to compress: $games_left_to_compress"
|
||||
compress_game "$compression_format" "$file" "$system"
|
||||
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
|
||||
if [[ -f "${file%.*}.$compatible_compression_format" ]]; then
|
||||
if [[ "$file" == *".cue" ]]; then
|
||||
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
||||
local file_path=$(dirname "$(realpath "$file")")
|
||||
while IFS= read -r line
|
||||
do
|
||||
log i "Removing file $file_path/$line"
|
||||
rm -f "$file_path/$line"
|
||||
done < <(printf '%s\n' "$cue_bin_files")
|
||||
log i "Removing file $(realpath $file)"
|
||||
rm -f $(realpath "$file")
|
||||
else
|
||||
log i "Removing file $(realpath $file)"
|
||||
rm -f "$(realpath "$file")"
|
||||
fi
|
||||
else
|
||||
log i "Compressed file ${file%.*}.$compatible_compression_format not found, skipping original file deletion"
|
||||
configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "Compression of $(basename $file) failed, skipping deletion."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
) |
|
||||
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --auto-close \
|
||||
|
|
Loading…
Reference in a new issue