mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2025-04-10 19:15:12 +00:00
Fix issue with "Compress Selected" button in Configurator multi-game compression, and multi-thread Zenity Configurator compression process.
This commit is contained in:
parent
62b86a12ec
commit
b5f4edc735
|
|
@ -910,7 +910,7 @@ configurator_compress_multiple_games_dialog() {
|
||||||
local choice=$(rd_zenity \
|
local choice=$(rd_zenity \
|
||||||
--list --width=1200 --height=720 --title "RetroDECK Configurator - Compression Tool" \
|
--list --width=1200 --height=720 --title "RetroDECK Configurator - Compression Tool" \
|
||||||
--checklist --hide-column=3 --ok-label="Compress Selected" --extra-button="Compress All" \
|
--checklist --hide-column=3 --ok-label="Compress Selected" --extra-button="Compress All" \
|
||||||
--separator=$'\0' --print-column=3 \
|
--separator="^" --print-column=3 \
|
||||||
--text="Choose which games to compress:" \
|
--text="Choose which games to compress:" \
|
||||||
--column "Compress?" \
|
--column "Compress?" \
|
||||||
--column "Game" \
|
--column "Game" \
|
||||||
|
|
@ -919,11 +919,13 @@ configurator_compress_multiple_games_dialog() {
|
||||||
|
|
||||||
local rc=$?
|
local rc=$?
|
||||||
log d "User choice: $choice"
|
log d "User choice: $choice"
|
||||||
if [[ $rc == 0 && -n "$choice" ]]; then
|
if [[ $rc == 0 && -n "$choice" && ! "$choice" == "Compress All" ]]; then
|
||||||
while IFS="^" read -r game comp; do # Split Zenity choice string into compatible pairs (game^format)
|
IFS='^' read -r -a temp_array <<< "$choice"
|
||||||
games_to_compress+=("$game"^"$comp")
|
games_to_compress=()
|
||||||
done <<< "$choice"
|
for ((i=0; i<${#temp_array[@]}; i+=2)); do
|
||||||
elif [[ -n "$choice" ]]; then
|
games_to_compress+=("${temp_array[i]}^${temp_array[i+1]}")
|
||||||
|
done
|
||||||
|
elif [[ "$choice" == "Compress All" ]]; then
|
||||||
games_to_compress=("${all_compressible_games[@]}")
|
games_to_compress=("${all_compressible_games[@]}")
|
||||||
else
|
else
|
||||||
configurator_compression_tool_dialog
|
configurator_compression_tool_dialog
|
||||||
|
|
@ -936,6 +938,7 @@ configurator_compress_multiple_games_dialog() {
|
||||||
|
|
||||||
local total_games=${#games_to_compress[@]}
|
local total_games=${#games_to_compress[@]}
|
||||||
local games_left=$total_games
|
local games_left=$total_games
|
||||||
|
local threads_running=0
|
||||||
|
|
||||||
(
|
(
|
||||||
for game_line in "${games_to_compress[@]}"; do
|
for game_line in "${games_to_compress[@]}"; do
|
||||||
|
|
@ -946,13 +949,23 @@ configurator_compress_multiple_games_dialog() {
|
||||||
log i "Compressing $(basename "$game") into $compression_format format"
|
log i "Compressing $(basename "$game") into $compression_format format"
|
||||||
|
|
||||||
echo "#Compressing $(basename "$game") into $compression_format format.\n\n$games_left games left to compress." # Update Zenity dialog text
|
echo "#Compressing $(basename "$game") into $compression_format format.\n\n$games_left games left to compress." # Update Zenity dialog text
|
||||||
compress_game "$compression_format" "$game" "$post_compression_cleanup" "$system"
|
|
||||||
|
compress_game "$compression_format" "$game" "$post_compression_cleanup" "$system" & ((threads_running++))
|
||||||
|
|
||||||
|
# If running jobs reach the limit, wait for one to finish
|
||||||
|
if (( threads_running >= max_threads )); then
|
||||||
|
wait -n # Wait for any one job to finish (requires Bash 4.3+)
|
||||||
|
((threads_running--))
|
||||||
|
fi
|
||||||
|
|
||||||
games_left=$(( games_left - 1 ))
|
games_left=$(( games_left - 1 ))
|
||||||
local progress=$(( 99 - (( 99 / total_games ) * games_left) ))
|
local progress=$(( 99 - (( 99 / total_games ) * games_left) ))
|
||||||
log d "progress: $progress"
|
log d "progress: $progress"
|
||||||
echo "$progress" # Update Zenity dialog progress bar
|
echo "$progress" # Update Zenity dialog progress bar
|
||||||
done
|
done
|
||||||
|
|
||||||
|
wait # wait for any straggling threads
|
||||||
|
|
||||||
echo "100" # Close Zenity progress dialog when finished
|
echo "100" # Close Zenity progress dialog when finished
|
||||||
) |
|
) |
|
||||||
rd_zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --auto-close \
|
rd_zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --auto-close \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue