From 43cfb617b64c018fae980b39cb52da30c2201308 Mon Sep 17 00:00:00 2001 From: zontreck Date: Sun, 29 Jun 2025 11:46:22 -0700 Subject: [PATCH] If the archive is not found, detect a tar error, and remove the temporary files. --- LinuxGeneralCompiler/dlvs.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/LinuxGeneralCompiler/dlvs.sh b/LinuxGeneralCompiler/dlvs.sh index 028d684..b48a1bc 100644 --- a/LinuxGeneralCompiler/dlvs.sh +++ b/LinuxGeneralCompiler/dlvs.sh @@ -10,7 +10,7 @@ download_game() { if [[ $version == *"-"* ]]; then url="https://cdn.vintagestory.at/gamefiles/unstable/vs_server_linux-x64_${version}.tar.gz" else - url="https://cdn.virtualstory.at/gamefiles/stable/vs_server_linux-x64_${version}.tar.gz" + url="https://cdn.vintagestory.at/gamefiles/stable/vs_server_linux-x64_${version}.tar.gz" fi # Check if extract path already exists and is not empty @@ -26,8 +26,18 @@ download_game() { # Extract and clean up mkdir -pv $extract_path cd $extract_path - tar -xvf "${download_path}.tar.gz" && rm "${download_path}"/"${version}"*.tar.gz - cd / + tar -xvf "${download_path}.tar.gz" && rm "${download_path}.tar.gz" + + if [ $? -eq 0 ] + then + cd / + echo "Successfully downloaded and extracted $version to $extract_path" + else + rm -rf "$download_path" + rm -rf "$extract_path" + echo "Game version was not found. Something went wrong. Cleaning up artifacts..." + cd / + fi } # Call the function with version as argument (e.g. "1.20.12")