Repository navigation
fix(core): propagate archive extraction and copy failures - #5109
Open
guilherme-praca wants to merge 1 commit into
Open
guilherme-praca wants to merge 1 commit into
guilherme-praca wants to merge 1 commit into
Conversation
fn_dl_extract could report success when nothing was extracted: - an unsupported MIME type matched no branch and the if returned 0 - in selective ZIP extraction the status came from rm, hiding unzip and cp failures Fail explicitly on unsupported archive types, chain unzip and cp so either failure is reported, clean up the temp directory only after capturing the exit code, and capture stderr so the failure reason is written to the log.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
fn_dl_extractcould print "OK" and return 0 without extracting anything:ifreturned 0.extractsrcset) the captured status came fromrm -rf, hiding failures fromunzip(e.g.extractsrcnot in the archive) and fromcp.Changes:
elsebranch that fails withUnsupported archive type: <mime>.unzip && cpinside the captured command, so either failure sets the exit code.exitcodeis captured, so cleanup cannot mask a failure.2>&1) of tar/unzip/cp, so the reason ends up inextractcmdand the script log instead of only on the terminal.Fixes #5048
Affected servers: all servers that download archives through
fn_dl_extract(install, update and fix modules, e.g. ts3, mta, fctr, xnt, jk2, steamcmd bootstrap).Type of change
Testing
fn_dl_extractfromdevelopand from this branch with stubbed print/log/exit functions and ran both against the same fixtures (tar.gz, tar.bz2, tar.xz, zip; truncated tar.xz and zip; plain text file; missingextractsrcfor zip and tar.gz; read-only destination for selective zip).shellcheck -S warning lgsm/modules/core_dl.shis clean.extractsrcmissingcpfailsextractsrcmissingTemp directory is removed in every case. Also checked: a downloaded HTML error page (
text/html) and a plain.tarnow fail as unsupported..tar.gz,.tar.bz2,.tar.xzor.zip(install_server_files, fix_, core_steamcmd, update_, and all 55 entries inmods_list.sh), so none relied on the old silent success.fileis a required dependency in every distro CSV.Failure propagation and
exitbypassfn_update_applyruns download and extraction in a subshell withexitbypassunset (command_update.sh), so a failed extraction stops the update.exitbypassis set,core_exit.shreturns instead of exiting, so the caller keeps going. One reachable case iscommand_update.sh→exitbypass=1 command_start.sh→check_steamcmd.sh→fn_install_steamcmd, which would continue tochmod +x steamcmd.shafter a failed extraction. This is the same for everycore_exit.shcall incore_dl.sh, and areturn 1alone would not help because the callers do not check the return status, so I left it out of this PR. Happy to follow up if you want a specific approach.Risk and rollback
unzipwarning (exit 1) now fails, as it already did for full ZIP extraction. On success, tar/unzip warnings are no longer printed live.Breaking changes
Documentation
Checklist