Browse Source

fix(fastdl): update bzip2 support check and adjust FastDL command conditions

pull/4472/head
Daniel Gibbs 2 weeks ago
parent
commit
ed4dcec028
  1. 40
      lgsm/modules/command_fastdl.sh
  2. 2
      lgsm/modules/core_getopt.sh

40
lgsm/modules/command_fastdl.sh

@ -20,17 +20,6 @@ addonsdir="${systemdir}/addons"
luasvautorundir="${systemdir}/lua/autorun/server"
luafastdlfile="lgsm_cl_force_fastdl.lua"
luafastdlfullpath="${luasvautorundir}/${luafastdlfile}"
# Only Source supports bzip2 compression.
if [ "${engine}" == "source" ]; then
supportsbzip=""
fi
# Check if bzip2 is installed.
if [ -v supportsbzip ] && [ ! "$(command -v bzip2 2> /dev/null)" ]; then
fn_print_fail "bzip2 is not installed"
fn_script_log_fail "bzip2 is not installed"
core_exit.sh
fi
# Header
fn_print_header
@ -116,13 +105,13 @@ fn_fastdl_dirs() {
# Using this gist https://gist.github.com/agunnerson-ibm/efca449565a3e7356906
fn_human_readable_file_size() {
local abbrevs=(
$((1 << 60)):ZB
$((1 << 50)):EB
$((1 << 40)):TB
$((1 << 30)):GB
$((1 << 20)):MB
$((1 << 10)):KB
$((1)):bytes
"1152921504606846976:ZB"
"1125899906842624:EB"
"1099511627776:TB"
"1073741824:GB"
"1048576:MB"
"1024:KB"
"1:bytes"
)
local bytes="${1}"
@ -229,14 +218,17 @@ fn_fastdl_preview() {
fn_script_log_fail "Generating file list."
core_exit.sh
fi
if [ -v supportsbzip ]; then
compressionmessage="about to compress ${totalfiles} files, "
if [ "${engine}" == "source" ]; then
echo -e "about to compress ${totalfiles} files, total size $(fn_human_readable_file_size "${filesizetotal}" 0)"
elif [ "${engine}" == "goldsrc" ]; then
echo -e "about to copy ${totalfiles} files, total size $(fn_human_readable_file_size "${filesizetotal}" 0)"
fi
echo -e "${compressionmessage}total size $(fn_human_readable_file_size ${filesizetotal} 0)"
fn_script_log_info "${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0)"
fn_script_log_info "${totalfiles} files, total size $(fn_human_readable_file_size "${filesizetotal}" 0)"
rm -f "${tmpdir:?}/fastdl_files_to_compress.txt"
if ! fn_prompt_yn "Continue?" Y; then
fn_script_log "User exited"
exitcode=0
core_exit.sh
fi
}
@ -438,7 +430,7 @@ fn_fastdl_preview
fn_clear_old_fastdl
fn_fastdl_dirs
fn_fastdl_build
if [ -v supportsbzip ]; then
if [ "${engine}" == "source" ]; then
fn_fastdl_bzip2
fi
# Finished message.

2
lgsm/modules/core_getopt.sh

@ -94,7 +94,7 @@ fi
## Game server exclusive commands.
# FastDL command.
if [ "${engine}" == "source" ] || [ "${shortname}" == "hldm" ]; then
if [ "${engine}" == "source" ] || [ "${engine}" == "goldsrc" ]; then
currentopt+=("${cmd_fastdl[@]}")
fi

Loading…
Cancel
Save