From 6631389765f604f4794251b4e02f75b1f0c62c23 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Thu, 30 May 2024 10:51:55 -0400 Subject: [PATCH 01/10] Rename functions.sh to other_functions.sh --- functions/global.sh | 2 +- functions/{functions.sh => other_functions.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename functions/{functions.sh => other_functions.sh} (100%) diff --git a/functions/global.sh b/functions/global.sh index 704d7f9f..f7df1337 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -7,7 +7,7 @@ source /app/libexec/checks.sh source /app/libexec/compression.sh source /app/libexec/dialogs.sh source /app/libexec/logger.sh -source /app/libexec/functions.sh +source /app/libexec/other_functions.sh source /app/libexec/multi_user.sh source /app/libexec/framework.sh source /app/libexec/post_update.sh diff --git a/functions/functions.sh b/functions/other_functions.sh similarity index 100% rename from functions/functions.sh rename to functions/other_functions.sh From 8a6a6551b09143bbb12ee790229428772c7506a9 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Thu, 30 May 2024 10:52:44 -0400 Subject: [PATCH 02/10] Create and source configurator_functions.sh --- functions/configurator_functions.sh | 0 functions/global.sh | 1 + 2 files changed, 1 insertion(+) create mode 100644 functions/configurator_functions.sh diff --git a/functions/configurator_functions.sh b/functions/configurator_functions.sh new file mode 100644 index 00000000..e69de29b diff --git a/functions/global.sh b/functions/global.sh index f7df1337..1fa480f3 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -13,6 +13,7 @@ source /app/libexec/framework.sh source /app/libexec/post_update.sh source /app/libexec/prepare_component.sh source /app/libexec/presets.sh +source /app/libexec/configurator_fuctions.sh # Static variables rd_conf="/var/config/retrodeck/retrodeck.cfg" # RetroDECK config file path From 6524ff1beb9b8aa92b7cbcf28c3ec0b6a9ecf97c Mon Sep 17 00:00:00 2001 From: icenine451 Date: Thu, 30 May 2024 10:54:29 -0400 Subject: [PATCH 03/10] Migrate existing configurator-related functions to configurator_functions.sh --- functions/configurator_functions.sh | 31 ++++++++++++++++++++++++++++ functions/other_functions.sh | 32 +---------------------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/functions/configurator_functions.sh b/functions/configurator_functions.sh index e69de29b..4b7d66a1 100644 --- a/functions/configurator_functions.sh +++ b/functions/configurator_functions.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +check_bios_files() { + # This function validates all the BIOS files listed in the $bios_checklist and adds the results to an array called bios_checked_list which can be used elsewhere + # There is a "basic" and "expert" mode which outputs different levels of data + # USAGE: check_bios_files "mode" + + rm -f "$godot_bios_files_checked" # Godot data transfer temp files + touch "$godot_bios_files_checked" + + while IFS="^" read -r bios_file bios_subdir bios_hash bios_system bios_desc + do + bios_file_found="No" + bios_hash_matched="No" + if [[ -f "$bios_folder/$bios_subdir$bios_file" ]]; then + bios_file_found="Yes" + if [[ $bios_hash == "Unknown" ]]; then + bios_hash_matched="Unknown" + elif [[ $(md5sum "$bios_folder/$bios_subdir$bios_file" | awk '{ print $1 }') == "$bios_hash" ]]; then + bios_hash_matched="Yes" + fi + fi + if [[ "$1" == "basic" ]]; then + bios_checked_list=("${bios_checked_list[@]}" "$bios_file" "$bios_system" "$bios_file_found" "$bios_hash_matched" "$bios_desc") + echo "$bios_file"^"$bios_system"^"$bios_file_found"^"$bios_hash_matched"^"$bios_desc" >> "$godot_bios_files_checked" # Godot data transfer temp file + else + bios_checked_list=("${bios_checked_list[@]}" "$bios_file" "$bios_system" "$bios_file_found" "$bios_hash_matched" "$bios_desc" "$bios_subdir" "$bios_hash") + echo "$bios_file"^"$bios_system"^"$bios_file_found"^"$bios_hash_matched"^"$bios_desc"^"$bios_subdir"^"$bios_hash" >> "$godot_bios_files_checked" # Godot data transfer temp file + fi + done < $bios_checklist +} diff --git a/functions/other_functions.sh b/functions/other_functions.sh index b8ea9953..2c6f9947 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -286,36 +286,6 @@ dir_prep() { log i "$symlink is now $real" } -check_bios_files() { - # This function validates all the BIOS files listed in the $bios_checklist and adds the results to an array called bios_checked_list which can be used elsewhere - # There is a "basic" and "expert" mode which outputs different levels of data - # USAGE: check_bios_files "mode" - - rm -f "$godot_bios_files_checked" # Godot data transfer temp files - touch "$godot_bios_files_checked" - - while IFS="^" read -r bios_file bios_subdir bios_hash bios_system bios_desc - do - bios_file_found="No" - bios_hash_matched="No" - if [[ -f "$bios_folder/$bios_subdir$bios_file" ]]; then - bios_file_found="Yes" - if [[ $bios_hash == "Unknown" ]]; then - bios_hash_matched="Unknown" - elif [[ $(md5sum "$bios_folder/$bios_subdir$bios_file" | awk '{ print $1 }') == "$bios_hash" ]]; then - bios_hash_matched="Yes" - fi - fi - if [[ "$1" == "basic" ]]; then - bios_checked_list=("${bios_checked_list[@]}" "$bios_file" "$bios_system" "$bios_file_found" "$bios_hash_matched" "$bios_desc") - echo "$bios_file"^"$bios_system"^"$bios_file_found"^"$bios_hash_matched"^"$bios_desc" >> "$godot_bios_files_checked" # Godot data transfer temp file - else - bios_checked_list=("${bios_checked_list[@]}" "$bios_file" "$bios_system" "$bios_file_found" "$bios_hash_matched" "$bios_desc" "$bios_subdir" "$bios_hash") - echo "$bios_file"^"$bios_system"^"$bios_file_found"^"$bios_hash_matched"^"$bios_desc"^"$bios_subdir"^"$bios_hash" >> "$godot_bios_files_checked" # Godot data transfer temp file - fi - done < $bios_checklist -} - update_rpcs3_firmware() { create_dir "$roms_folder/ps3/tmp" chmod 777 "$roms_folder/ps3/tmp" @@ -699,7 +669,7 @@ ponzu() { rm -rf "$rdhome/ponzu" } -ponzu_remove(){ +ponzu_remove() { # Call me with yuzu or citra and I will remove them From 6d2eb27c87c67189f6cc6da6dbba470a12a1857f Mon Sep 17 00:00:00 2001 From: icenine451 Date: Thu, 30 May 2024 10:58:11 -0400 Subject: [PATCH 04/10] Add Godot temp file location initialization --- functions/global.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions/global.sh b/functions/global.sh index 1fa480f3..67c52476 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -132,6 +132,11 @@ if [[ ! -d "$rd_logs_folder/ES-DE" ]]; then dir_prep "$rd_logs_folder/ES-DE" "$es_source_logs" fi +# Initialize location of Godot temp data files, if it doesn't exist +if [[ ! -d "/var/config/retrodeck/godot" ]]; then + create_dir "/var/config/retrodeck/godot" +fi + # We moved the lockfile in /var/config/retrodeck in order to solve issue #53 - Remove in a few versions if [[ -f "$HOME/retrodeck/.lock" ]]; then mv "$HOME/retrodeck/.lock" $lockfile From 2374d6e7fec0e2e382b3f43ddc13401f50198579 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Thu, 30 May 2024 10:59:47 -0400 Subject: [PATCH 05/10] Only remove Godot temp file if it exists, cut down on errors --- functions/configurator_functions.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/configurator_functions.sh b/functions/configurator_functions.sh index 4b7d66a1..aa0618f4 100644 --- a/functions/configurator_functions.sh +++ b/functions/configurator_functions.sh @@ -5,7 +5,9 @@ check_bios_files() { # There is a "basic" and "expert" mode which outputs different levels of data # USAGE: check_bios_files "mode" - rm -f "$godot_bios_files_checked" # Godot data transfer temp files + if [[ -f "$godot_bios_files_checked" ]]; then + rm -f "$godot_bios_files_checked" # Godot data transfer temp files + fi touch "$godot_bios_files_checked" while IFS="^" read -r bios_file bios_subdir bios_hash bios_system bios_desc From 8411e064d168ac43f5e3f3b4c25b8274837abaf4 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Thu, 30 May 2024 11:30:46 -0400 Subject: [PATCH 06/10] Extract preset change selection from Zenity for use in Godot --- functions/global.sh | 1 + functions/presets.sh | 64 +++++++++++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/functions/global.sh b/functions/global.sh index 67c52476..0c4cd4ed 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -53,6 +53,7 @@ pretty_system_names_reference_list="$emuconfigs/defaults/retrodeck/reference_lis # Godot data transfer temp files godot_bios_files_checked="/var/config/retrodeck/godot/godot_bios_files_checked.tmp" +godot_current_preset_settings="/var/config/retrodeck/godot/godot_current_preset_settings.tmp" # Config files for emulators with single config files diff --git a/functions/presets.sh b/functions/presets.sh index 19fcbcec..94bf7761 100644 --- a/functions/presets.sh +++ b/functions/presets.sh @@ -4,6 +4,43 @@ change_preset_dialog() { # This function will build a list of all systems compatible with a given preset, their current enable/disabled state and allow the user to change one or more # USAGE: change_preset_dialog "$preset" + build_preset_list_options "$1" + + choice=$(zenity \ + --list --width=1200 --height=720 \ + --checklist \ + --separator="," \ + --hide-column=3 --print-column=3 \ + --text="Enable $pretty_preset_name:" \ + --column "Enabled" \ + --column "Emulator" \ + --column "internal_system_name" \ + "${current_preset_settings[@]}") + + local rc=$? + + if [[ ! -z $choice || "$rc" == 0 ]]; then + ( + make_preset_changes + ) | + 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 - Presets Configuration" \ + --text="Setting up your presets, please wait..." + else + echo "No choices made" + fi +} + +build_preset_list_options() { + # This function will build a list of all the systems available for a given preset + # The list will be generated into a Godot temp file and the variable $current_preset_settings + + if [[ -f "$godot_current_preset_settings" ]]; then + rm -f "$godot_current_preset_settings" # Godot data transfer temp files + fi + touch "$godot_current_preset_settings" + local preset="$1" pretty_preset_name=${preset//_/ } # Preset name prettification pretty_preset_name=$(echo $pretty_preset_name | awk '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1))substr($i,2)}}1') # Preset name prettification @@ -25,24 +62,15 @@ change_preset_dialog() { current_disabled_systems=("${current_disabled_systems[@]}" "$system_name") fi current_preset_settings=("${current_preset_settings[@]}" "$system_value" "$(make_name_pretty $system_name)" "$system_name") + echo "$system_value"^"$(make_name_pretty $system_name)"^"$system_name" >> "$godot_current_preset_settings" done < <(printf '%s\n' "$section_results") +} - choice=$(zenity \ - --list --width=1200 --height=720 \ - --checklist \ - --separator="," \ - --hide-column=3 --print-column=3 \ - --text="Enable $pretty_preset_name:" \ - --column "Enabled" \ - --column "Emulator" \ - --column "internal_system_name" \ - "${current_preset_settings[@]}") - local rc=$? +make_preset_changes() { + # This function will take an array $choices, which contains the names of systems that have been enabled for this preset and enable them in the backend - if [[ ! -z $choice || "$rc" == 0 ]]; then - ( - IFS="," read -ra choices <<< "$choice" + IFS="," read -ra choices <<< "$choice" for emulator in "${all_systems[@]}"; do if [[ " ${choices[*]} " =~ " ${emulator} " && ! " ${current_enabled_systems[*]} " =~ " ${emulator} " ]]; then changed_systems=("${changed_systems[@]}" "$emulator") @@ -71,14 +99,6 @@ change_preset_dialog() { for emulator in "${changed_systems[@]}"; do build_preset_config $emulator ${changed_presets[*]} done - ) | - 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 - Presets Configuration" \ - --text="Setting up your presets, please wait..." - else - echo "No choices made" - fi } build_preset_config() { From 38d86581e43fe5b4ff7a8e35940985de688c223f Mon Sep 17 00:00:00 2001 From: icenine451 Date: Thu, 30 May 2024 11:30:56 -0400 Subject: [PATCH 07/10] Fix comment for readability --- functions/configurator_functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/configurator_functions.sh b/functions/configurator_functions.sh index aa0618f4..a9e138fb 100644 --- a/functions/configurator_functions.sh +++ b/functions/configurator_functions.sh @@ -1,7 +1,7 @@ #!/bin/bash check_bios_files() { - # This function validates all the BIOS files listed in the $bios_checklist and adds the results to an array called bios_checked_list which can be used elsewhere + # This function validates all the BIOS files listed in the $bios_checklist and adds the results to an array called $bios_checked_list which can be used elsewhere # There is a "basic" and "expert" mode which outputs different levels of data # USAGE: check_bios_files "mode" From 2afcf2ead46aa9cfa2940e2f23cc10b347914470 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Thu, 30 May 2024 11:35:42 -0400 Subject: [PATCH 08/10] Move post-compression file cleanup to compress_game function to avoid repetition --- functions/compression.sh | 23 +++++++++++++++++++++ tools/configurator.sh | 43 ---------------------------------------- 2 files changed, 23 insertions(+), 43 deletions(-) diff --git a/functions/compression.sh b/functions/compression.sh index 9616a2c3..fc726d80 100644 --- a/functions/compression.sh +++ b/functions/compression.sh @@ -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() { diff --git a/tools/configurator.sh b/tools/configurator.sh index 1808ea8a..73588a07 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -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 \ From 7fc79b49ea600746fe4434c7778bd0a01dadc9e1 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Thu, 30 May 2024 12:17:28 -0400 Subject: [PATCH 09/10] Extract game compression functions from Zenity for use in Godot --- functions/compression.sh | 65 ++++++++++++++++++++++++++++++++++++++++ functions/global.sh | 1 + tools/configurator.sh | 49 +----------------------------- 3 files changed, 67 insertions(+), 48 deletions(-) diff --git a/functions/compression.sh b/functions/compression.sh index fc726d80..96c2ea52 100644 --- a/functions/compression.sh +++ b/functions/compression.sh @@ -119,6 +119,71 @@ validate_for_chd() { fi } +find_compatible_games() { + # The function takes the following arguments, which alter what files are compressed: + # "everything" - Compresses all games found into their compatible formats + # "all" - Compresses a list of user-chosen files into their compatible formats + # "chd" or "zip" or "rvz" - Compresses a list of user-chosen files into the given format + + if [[ -f "$godot_compression_compatible_games" ]]; then + rm -f "$godot_compression_compatible_games" # Godot data transfer temp files + fi + touch "$godot_compression_compatible_games" + + local compressable_games_list=() + local all_compressable_games=() + local games_to_compress=() + local target_selection="$1" + + if [[ "$1" == "everything" ]]; then + local compression_format="all" + else + local compression_format="$1" + fi + + if [[ $compression_format == "all" ]]; then + local compressable_systems_list=$(cat $compression_targets | sed '/^$/d' | sed '/^\[/d') + else + local compressable_systems_list=$(sed -n '/\['"$compression_format"'\]/, /\[/{ /\['"$compression_format"'\]/! { /\[/! p } }' $compression_targets | sed '/^$/d') + fi + + while IFS= read -r system # Find and validate all games that are able to be compressed with this compression type + do + compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt") + if [[ ! -z $compression_candidates ]]; then + while IFS= read -r game + do + local compatible_compression_format=$(find_compatible_compression_format "$game") + if [[ $compression_format == "chd" ]]; then + if [[ $compatible_compression_format == "chd" ]]; then + all_compressable_games=("${all_compressable_games[@]}" "$game") + compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game") + echo "${game}"^"$compatible_compression_format" >> "$godot_compression_compatible_games" + fi + elif [[ $compression_format == "zip" ]]; then + if [[ $compatible_compression_format == "zip" ]]; then + all_compressable_games=("${all_compressable_games[@]}" "$game") + compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game") + echo "${game}"^"$compatible_compression_format" >> "$godot_compression_compatible_games" + fi + elif [[ $compression_format == "rvz" ]]; then + if [[ $compatible_compression_format == "rvz" ]]; then + all_compressable_games=("${all_compressable_games[@]}" "$game") + compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game") + echo "${game}"^"$compatible_compression_format" >> "$godot_compression_compatible_games" + fi + elif [[ $compression_format == "all" ]]; then + if [[ ! $compatible_compression_format == "none" ]]; then + all_compressable_games=("${all_compressable_games[@]}" "$game") + compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game") + echo "${game}"^"$compatible_compression_format" >> "$godot_compression_compatible_games" + fi + fi + done < <(printf '%s\n' "$compression_candidates") + fi + done < <(printf '%s\n' "$compressable_systems_list") +} + cli_compress_single_game() { # This function will compress a single file passed from the CLI arguments # USAGE: cli_compress_single_game $full_file_path diff --git a/functions/global.sh b/functions/global.sh index 0c4cd4ed..e2b0257b 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -54,6 +54,7 @@ pretty_system_names_reference_list="$emuconfigs/defaults/retrodeck/reference_lis godot_bios_files_checked="/var/config/retrodeck/godot/godot_bios_files_checked.tmp" godot_current_preset_settings="/var/config/retrodeck/godot/godot_current_preset_settings.tmp" +godot_compression_compatible_games="/var/config/retrodeck/godot/godot_compression_compatible_games.tmp" # Config files for emulators with single config files diff --git a/tools/configurator.sh b/tools/configurator.sh index 73588a07..7a0bb1be 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -813,54 +813,7 @@ configurator_compress_single_game_dialog() { configurator_compress_multiple_games_dialog() { # This dialog will display any games it finds to be compressable, from the systems listed under each compression type in compression_targets.cfg - local compressable_games_list=() - local all_compressable_games=() - local games_to_compress=() - local target_selection="$1" - - if [[ "$1" == "everything" ]]; then - local compression_format="all" - else - local compression_format="$1" - fi - - if [[ $compression_format == "all" ]]; then - local compressable_systems_list=$(cat $compression_targets | sed '/^$/d' | sed '/^\[/d') - else - local compressable_systems_list=$(sed -n '/\['"$compression_format"'\]/, /\[/{ /\['"$compression_format"'\]/! { /\[/! p } }' $compression_targets | sed '/^$/d') - fi - - while IFS= read -r system # Find and validate all games that are able to be compressed with this compression type - do - compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt") - if [[ ! -z $compression_candidates ]]; then - while IFS= read -r game - do - local compatible_compression_format=$(find_compatible_compression_format "$game") - if [[ $compression_format == "chd" ]]; then - if [[ $compatible_compression_format == "chd" ]]; then - all_compressable_games=("${all_compressable_games[@]}" "$game") - compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game") - fi - elif [[ $compression_format == "zip" ]]; then - if [[ $compatible_compression_format == "zip" ]]; then - all_compressable_games=("${all_compressable_games[@]}" "$game") - compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game") - fi - elif [[ $compression_format == "rvz" ]]; then - if [[ $compatible_compression_format == "rvz" ]]; then - all_compressable_games=("${all_compressable_games[@]}" "$game") - compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game") - fi - elif [[ $compression_format == "all" ]]; then - if [[ ! $compatible_compression_format == "none" ]]; then - all_compressable_games=("${all_compressable_games[@]}" "$game") - compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game") - fi - fi - done < <(printf '%s\n' "$compression_candidates") - fi - done < <(printf '%s\n' "$compressable_systems_list") + find_compatible_games "$1" if [[ ! "$target_selection" == "everything" ]]; then # If the user chose to not auto-compress everything choice=$(zenity \ From 37f120119b94b16927102eb54f29333cb2ab6dcb Mon Sep 17 00:00:00 2001 From: icenine451 Date: Thu, 30 May 2024 12:18:08 -0400 Subject: [PATCH 10/10] Remove duplicate compression cleanup from CLI compression --- functions/compression.sh | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/functions/compression.sh b/functions/compression.sh index 96c2ea52..3e09dc1e 100644 --- a/functions/compression.sh +++ b/functions/compression.sh @@ -197,26 +197,6 @@ cli_compress_single_game() { if [[ ! $compatible_compression_format == "none" ]]; then log i "$(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")") - while IFS= read -r line - do # Remove associated .bin files - log i "Removing original file "$file_path/$line"" - rm -f "$file_path/$line" - done < <(printf '%s\n' "$cue_bin_files") # Remove original .cue file - log i "Removing original file $(basename "$file")" - rm -f "$file" - else - log i "Removing original file $(basename "$file")" - rm -f "$file" - fi - else - log w "Compressed version of $(basename "$file") not found, skipping deletion." - fi - fi else log w "$(basename "$file") does not have any compatible compression formats." fi @@ -259,26 +239,6 @@ cli_compress_all_games() { if [[ ! "$compatible_compression_format" == "none" ]]; then log i "$(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")") - while IFS= read -r line - do # Remove associated .bin files - log i "Removing original file "$file_path/$line"" - rm -f "$file_path/$line" - done < <(printf '%s\n' "$cue_bin_files") # Remove original .cue file - log i "Removing original file "$file"" - rm -f $(realpath "$file") - else - log i "Removing original file "$file"" - rm -f $(realpath "$file") - fi - else - log w "Compressed version of $(basename "$file") not found, skipping deletion." - fi - fi else log w "No compatible compression format found for $(basename "$file")" fi