mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2025-04-10 19:15:12 +00:00
Multi-thread CLI multi-game compression
This commit is contained in:
parent
21a567097a
commit
b02274001b
|
|
@ -272,13 +272,22 @@ cli_compress_all_games() {
|
||||||
else
|
else
|
||||||
post_compression_cleanup="false"
|
post_compression_cleanup="false"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while IFS= read -r system # Find and validate all games that are able to be compressed with this compression type
|
while IFS= read -r system # Find and validate all games that are able to be compressed with this compression type
|
||||||
do
|
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
|
||||||
|
(
|
||||||
local compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt")
|
local compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt")
|
||||||
if [[ ! -z "$compression_candidates" ]]; then
|
if [[ ! -z "$compression_candidates" ]]; then
|
||||||
log i "Checking files for $system"
|
log i "Checking files for $system"
|
||||||
while IFS= read -r file
|
while IFS= read -r file
|
||||||
do
|
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
|
||||||
|
(
|
||||||
local compatible_compression_format=$(find_compatible_compression_format "$file")
|
local compatible_compression_format=$(find_compatible_compression_format "$file")
|
||||||
if [[ ! "$compatible_compression_format" == "none" ]]; then
|
if [[ ! "$compatible_compression_format" == "none" ]]; then
|
||||||
log i "$(basename "$file") can be compressed to $compatible_compression_format"
|
log i "$(basename "$file") can be compressed to $compatible_compression_format"
|
||||||
|
|
@ -286,11 +295,15 @@ cli_compress_all_games() {
|
||||||
else
|
else
|
||||||
log w "No compatible compression format found for $(basename "$file")"
|
log w "No compatible compression format found for $(basename "$file")"
|
||||||
fi
|
fi
|
||||||
|
) &
|
||||||
done < <(printf '%s\n' "$compression_candidates")
|
done < <(printf '%s\n' "$compression_candidates")
|
||||||
|
wait # wait for background tasks to finish
|
||||||
else
|
else
|
||||||
log w "No compatible files found for compression in $system"
|
log w "No compatible files found for compression in $system"
|
||||||
fi
|
fi
|
||||||
|
) &
|
||||||
done < <(printf '%s\n' "$compressible_systems_list")
|
done < <(printf '%s\n' "$compressible_systems_list")
|
||||||
|
wait # wait for background tasks to finish
|
||||||
else
|
else
|
||||||
log i "The response for post-compression file cleanup was not correct. Please try again."
|
log i "The response for post-compression file cleanup was not correct. Please try again."
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue