Merge pull request #752 from icenine451/cooker-0.8.0b-icenine451

ROM compression safty additions
This commit is contained in:
icenine451 2024-04-02 09:54:40 -04:00 committed by GitHub
commit 80cb3d0f88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 60 additions and 44 deletions

View file

@ -111,6 +111,7 @@ cli_compress_single_game() {
echo "$(basename "$file") can be compressed to $compatible_compression_format"
compress_game "$compatible_compression_format" "$file" "$system"
if [[ $post_compression_cleanup == [yY] ]]; then # Remove file(s) if requested
if [[ -f "${file%.*}.$compatible_compression_format" ]]; then
if [[ $(basename "$file") == *".cue" ]]; then
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
local file_path=$(dirname "$(realpath "$file")")
@ -125,6 +126,9 @@ cli_compress_single_game() {
echo "Removing original file $(basename "$file")"
rm -f "$file"
fi
else
echo "Compressed version of $(basename "$file") not found, skipping deletion."
fi
fi
else
echo "$(basename "$file") does not have any compatible compression formats."
@ -169,6 +173,7 @@ cli_compress_all_games() {
echo "$(basename "$file") can be compressed to $compatible_compression_format"
compress_game "$compatible_compression_format" "$file" "$system"
if [[ $post_compression_cleanup == [yY] ]]; 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")")
@ -183,6 +188,9 @@ cli_compress_all_games() {
echo "Removing original file "$file""
rm -f $(realpath "$file")
fi
else
echo "Compressed version of $(basename "$file") not found, skipping deletion."
fi
fi
else
echo "No compatible compression format found for $(basename "$file")"

View file

@ -793,6 +793,7 @@ configurator_compress_single_game_dialog() {
echo "# 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
if [[ "$file" == *".cue" ]]; then
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
local file_path=$(dirname "$(realpath "$file")")
@ -804,12 +805,15 @@ configurator_compress_single_game_dialog() {
else
rm -f "$(realpath "$file")"
fi
else
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" \
--title "RetroDECK Configurator Utility - Compression in Progress"
configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "The compression process is complete!"
configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "The compression process is complete."
configurator_compression_tool_dialog
else
@ -910,6 +914,7 @@ configurator_compress_multiple_games_dialog() {
games_left_to_compress=$((games_left_to_compress-1))
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")")
@ -921,6 +926,9 @@ configurator_compress_multiple_games_dialog() {
else
rm -f "$(realpath "$file")"
fi
else
configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "Compression of $(basename $file) failed, skipping deletion."
fi
fi
done
) |
@ -938,7 +946,7 @@ configurator_compression_cleanup_dialog() {
zenity --icon-name=net.retrodeck.retrodeck --question --no-wrap --cancel-label="No" --ok-label="Yes" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator - RetroDECK: Compression Tool" \
--text="Do you want to remove old files after they are compressed?\n\nClicking \"No\" will leave all files behind which will need to be cleaned up manually and may result in game duplicates showing in the RetroDECK library."
--text="Do you want to remove old files after they are compressed?\n\nClicking \"No\" will leave all files behind which will need to be cleaned up manually and may result in game duplicates showing in the RetroDECK library.\n\nPlease make sure you have a backup of your ROMs before using automatic cleanup!"
local rc=$? # Capture return code, as "Yes" button has no text value
if [[ $rc == "0" ]]; then # If user clicked "Yes"
echo "true"