mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-25 15:35:38 +00:00
Add post-compression file check before original deletion
Add ROM backup disclaimer to compression auto-cleanup
This commit is contained in:
parent
50957bd574
commit
32ebb6e686
|
@ -111,19 +111,23 @@ cli_compress_single_game() {
|
||||||
echo "$(basename "$file") can be compressed to $compatible_compression_format"
|
echo "$(basename "$file") can be compressed to $compatible_compression_format"
|
||||||
compress_game "$compatible_compression_format" "$file" "$system"
|
compress_game "$compatible_compression_format" "$file" "$system"
|
||||||
if [[ $post_compression_cleanup == [yY] ]]; then # Remove file(s) if requested
|
if [[ $post_compression_cleanup == [yY] ]]; then # Remove file(s) if requested
|
||||||
if [[ $(basename "$file") == *".cue" ]]; then
|
if [[ -f "${file%.*}.$compatible_compression_format" ]]; then
|
||||||
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
if [[ $(basename "$file") == *".cue" ]]; then
|
||||||
local file_path=$(dirname "$(realpath "$file")")
|
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
||||||
while IFS= read -r line
|
local file_path=$(dirname "$(realpath "$file")")
|
||||||
do # Remove associated .bin files
|
while IFS= read -r line
|
||||||
echo "Removing original file "$file_path/$line""
|
do # Remove associated .bin files
|
||||||
rm -f "$file_path/$line"
|
echo "Removing original file "$file_path/$line""
|
||||||
done < <(printf '%s\n' "$cue_bin_files") # Remove original .cue file
|
rm -f "$file_path/$line"
|
||||||
echo "Removing original file $(basename "$file")"
|
done < <(printf '%s\n' "$cue_bin_files") # Remove original .cue file
|
||||||
rm -f "$file"
|
echo "Removing original file $(basename "$file")"
|
||||||
|
rm -f "$file"
|
||||||
|
else
|
||||||
|
echo "Removing original file $(basename "$file")"
|
||||||
|
rm -f "$file"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Removing original file $(basename "$file")"
|
echo "Compressed version of $(basename "$file") not found, skipping deletion."
|
||||||
rm -f "$file"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -169,19 +173,23 @@ cli_compress_all_games() {
|
||||||
echo "$(basename "$file") can be compressed to $compatible_compression_format"
|
echo "$(basename "$file") can be compressed to $compatible_compression_format"
|
||||||
compress_game "$compatible_compression_format" "$file" "$system"
|
compress_game "$compatible_compression_format" "$file" "$system"
|
||||||
if [[ $post_compression_cleanup == [yY] ]]; then # Remove file(s) if requested
|
if [[ $post_compression_cleanup == [yY] ]]; then # Remove file(s) if requested
|
||||||
if [[ "$file" == *".cue" ]]; then
|
if [[ -f "${file%.*}.$compatible_compression_format" ]]; then
|
||||||
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
if [[ "$file" == *".cue" ]]; then
|
||||||
local file_path=$(dirname "$(realpath "$file")")
|
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
||||||
while IFS= read -r line
|
local file_path=$(dirname "$(realpath "$file")")
|
||||||
do # Remove associated .bin files
|
while IFS= read -r line
|
||||||
echo "Removing original file "$file_path/$line""
|
do # Remove associated .bin files
|
||||||
rm -f "$file_path/$line"
|
echo "Removing original file "$file_path/$line""
|
||||||
done < <(printf '%s\n' "$cue_bin_files") # Remove original .cue file
|
rm -f "$file_path/$line"
|
||||||
echo "Removing original file "$file""
|
done < <(printf '%s\n' "$cue_bin_files") # Remove original .cue file
|
||||||
rm -f $(realpath "$file")
|
echo "Removing original file "$file""
|
||||||
|
rm -f $(realpath "$file")
|
||||||
|
else
|
||||||
|
echo "Removing original file "$file""
|
||||||
|
rm -f $(realpath "$file")
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Removing original file "$file""
|
echo "Compressed version of $(basename "$file") not found, skipping deletion."
|
||||||
rm -f $(realpath "$file")
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
|
@ -793,23 +793,27 @@ configurator_compress_single_game_dialog() {
|
||||||
echo "# Compressing $(basename "$file") to $compatible_compression_format format"
|
echo "# Compressing $(basename "$file") to $compatible_compression_format format"
|
||||||
compress_game "$compatible_compression_format" "$file" "$system"
|
compress_game "$compatible_compression_format" "$file" "$system"
|
||||||
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
|
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
|
||||||
if [[ "$file" == *".cue" ]]; then
|
if [[ -f "${file%.*}.$compatible_compression_format" ]]; then
|
||||||
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
if [[ "$file" == *".cue" ]]; then
|
||||||
local file_path=$(dirname "$(realpath "$file")")
|
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
||||||
while IFS= read -r line
|
local file_path=$(dirname "$(realpath "$file")")
|
||||||
do
|
while IFS= read -r line
|
||||||
rm -f "$file_path/$line"
|
do
|
||||||
done < <(printf '%s\n' "$cue_bin_files")
|
rm -f "$file_path/$line"
|
||||||
rm -f $(realpath "$file")
|
done < <(printf '%s\n' "$cue_bin_files")
|
||||||
|
rm -f $(realpath "$file")
|
||||||
|
else
|
||||||
|
rm -f "$(realpath "$file")"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
rm -f "$(realpath "$file")"
|
configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "A compressed version of the file was not found, skipping deletion."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
) |
|
) |
|
||||||
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
|
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
|
||||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||||
--title "RetroDECK Configurator Utility - Compression in Progress"
|
--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
|
configurator_compression_tool_dialog
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -910,16 +914,20 @@ configurator_compress_multiple_games_dialog() {
|
||||||
games_left_to_compress=$((games_left_to_compress-1))
|
games_left_to_compress=$((games_left_to_compress-1))
|
||||||
compress_game "$compression_format" "$file" "$system"
|
compress_game "$compression_format" "$file" "$system"
|
||||||
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
|
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
|
||||||
if [[ "$file" == *".cue" ]]; then
|
if [[ -f "${file%.*}.$compatible_compression_format" ]]; then
|
||||||
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
if [[ "$file" == *".cue" ]]; then
|
||||||
local file_path=$(dirname "$(realpath "$file")")
|
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
||||||
while IFS= read -r line
|
local file_path=$(dirname "$(realpath "$file")")
|
||||||
do
|
while IFS= read -r line
|
||||||
rm -f "$file_path/$line"
|
do
|
||||||
done < <(printf '%s\n' "$cue_bin_files")
|
rm -f "$file_path/$line"
|
||||||
rm -f $(realpath "$file")
|
done < <(printf '%s\n' "$cue_bin_files")
|
||||||
|
rm -f $(realpath "$file")
|
||||||
|
else
|
||||||
|
rm -f "$(realpath "$file")"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
rm -f "$(realpath "$file")"
|
configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "Compression of $(basename $file) failed, skipping deletion."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -938,7 +946,7 @@ configurator_compression_cleanup_dialog() {
|
||||||
zenity --icon-name=net.retrodeck.retrodeck --question --no-wrap --cancel-label="No" --ok-label="Yes" \
|
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" \
|
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||||
--title "RetroDECK Configurator - RetroDECK: Compression Tool" \
|
--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
|
local rc=$? # Capture return code, as "Yes" button has no text value
|
||||||
if [[ $rc == "0" ]]; then # If user clicked "Yes"
|
if [[ $rc == "0" ]]; then # If user clicked "Yes"
|
||||||
echo "true"
|
echo "true"
|
||||||
|
|
Loading…
Reference in a new issue