mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2025-04-10 19:15:12 +00:00
Multi-threaded find_compatible_games function for game compression process
This commit is contained in:
parent
a015bb6ec4
commit
7b76d3c7d8
|
@ -163,12 +163,20 @@ find_compatible_games() {
|
|||
log d "compression_targets: $compression_targets"
|
||||
|
||||
while IFS= read -r system; do
|
||||
while (( $(jobs -p | wc -l) >= $max_threads )); do # Wait for a background task to finish if max_threads has been hit
|
||||
sleep 0.1
|
||||
done
|
||||
(
|
||||
log d "Checking system: $system"
|
||||
if [[ -d "$roms_folder/$system" ]]; then
|
||||
local compression_candidates
|
||||
compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt")
|
||||
if [[ -n "$compression_candidates" ]]; then
|
||||
while IFS= read -r game; do
|
||||
while (( $(jobs -p | wc -l) >= $max_threads )); do # Wait for a background task to finish if max_threads has been hit
|
||||
sleep 0.1
|
||||
done
|
||||
(
|
||||
log d "Checking game: $game"
|
||||
local compatible_compression_format
|
||||
compatible_compression_format=$(find_compatible_compression_format "$game")
|
||||
|
@ -181,34 +189,50 @@ find_compatible_games() {
|
|||
"chd")
|
||||
if [[ "$compatible_compression_format" == "chd" ]]; then
|
||||
log d "Game $game is compatible with CHD compression"
|
||||
(
|
||||
flock -x 200
|
||||
echo "${game}^chd" >> "$output_file"
|
||||
) 200>"$RD_FILE_LOCK"
|
||||
fi
|
||||
;;
|
||||
"zip")
|
||||
if [[ "$compatible_compression_format" == "zip" ]]; then
|
||||
log d "Game $game is compatible with ZIP compression"
|
||||
(
|
||||
flock -x 200
|
||||
echo "${game}^zip" >> "$output_file"
|
||||
) 200>"$RD_FILE_LOCK"
|
||||
fi
|
||||
;;
|
||||
"rvz")
|
||||
if [[ "$compatible_compression_format" == "rvz" ]]; then
|
||||
log d "Game $game is compatible with RVZ compression"
|
||||
(
|
||||
flock -x 200
|
||||
echo "${game}^rvz" >> "$output_file"
|
||||
) 200>"$RD_FILE_LOCK"
|
||||
fi
|
||||
;;
|
||||
"all")
|
||||
if [[ "$compatible_compression_format" != "none" ]]; then
|
||||
log d "Game $game is compatible with $compatible_compression_format compression"
|
||||
(
|
||||
flock -x 200
|
||||
echo "${game}^${compatible_compression_format}" >> "$output_file"
|
||||
) 200>"$RD_FILE_LOCK"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
) &
|
||||
done < <(printf '%s\n' "$compression_candidates")
|
||||
wait # wait for background tasks to finish
|
||||
fi
|
||||
else
|
||||
log d "Rom folder for $system is missing, skipping"
|
||||
fi
|
||||
) &
|
||||
done < <(printf '%s\n' "$compressible_systems_list")
|
||||
wait # wait for background tasks to finish
|
||||
|
||||
log d "Compatible games have been written to $output_file"
|
||||
cat "$output_file"
|
||||
|
|
|
@ -92,6 +92,9 @@ features="$config/retrodeck/reference_lists/features.json"
|
|||
es_systems="/app/share/es-de/resources/systems/linux/es_systems.xml" # ES-DE supported system list
|
||||
es_find_rules="/app/share/es-de/resources/systems/linux/es_find_rules.xml" # ES-DE emulator find rules
|
||||
|
||||
# File lock file for multi-threaded write operations to the same file
|
||||
RD_FILE_LOCK="/tmp/retrodeck_file_lock"
|
||||
|
||||
# Godot data transfer temp files
|
||||
|
||||
godot_bios_files_checked="$XDG_CONFIG_HOME/retrodeck/godot/godot_bios_files_checked.tmp"
|
||||
|
|
Loading…
Reference in a new issue