From d2b90489538ba774914fc078e3dcbd582dfdcddd Mon Sep 17 00:00:00 2001 From: Dessa Simpson Date: Fri, 22 Apr 2022 14:21:48 -0700 Subject: [PATCH 1/2] Download spiget resources to tempdir under plugins Fixes #1485 --- scripts/start-spiget | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/start-spiget b/scripts/start-spiget index d6e184169bd..d86a2e8c614 100755 --- a/scripts/start-spiget +++ b/scripts/start-spiget @@ -47,7 +47,7 @@ getResourceFromSpiget() { mkdir -p /data/plugins versionfile="/data/plugins/.${resource}-version.json" - versionfileNew="/tmp/.${resource}-version.json" + versionfileNew="${versionfile}.tmp" if [ -f "$versionfile" ]; then if [[ -n $(find "$versionfile" -mmin +${SPIGET_DOWNLOAD_TOLERANCE}) ]]; then @@ -87,8 +87,10 @@ getResourceFromSpiget() { downloadResourceFromSpiget() { resource=${1?} + tempDir="/data/plugins/tmp-${resource}" + mkdir $tempDir resourceUrl="https://api.spiget.org/v2/resources/${resource}" - if ! outfile=$(get_silent --output-filename -o /tmp "${acceptArgs[@]}" "${resourceUrl}/download"); then + if ! outfile=$(get_silent --output-filename -o $tempDir "${acceptArgs[@]}" "${resourceUrl}/download"); then log "ERROR: failed to download resource '${resource}' from ${resourceUrl}/download" if externalUrl=$(get --json-path '$.file.externalUrl' "${resourceUrl}"); then log " Visit $externalUrl to pre-download the resource" @@ -107,11 +109,11 @@ downloadResourceFromSpiget() { elif containsJars "${outfile}"; then log "Extracting contents of resource ${resource} into plugins" extract "$outfile" /data/plugins - rm "$outfile" else log "ERROR: file for resource ${resource} has an unexpected file type: ${fileType}" exit 2 fi + rm -rf "$tempDir" } if [[ ${SPIGET_RESOURCES} ]]; then From ad62a9a8fca379976c12c815fca5a59dcd21f2ae Mon Sep 17 00:00:00 2001 From: Dessa Simpson Date: Sun, 1 May 2022 11:00:17 -0700 Subject: [PATCH 2/2] Add -p flag to mkdir $tempDir Co-authored-by: Geoff Bourne --- scripts/start-spiget | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/start-spiget b/scripts/start-spiget index d86a2e8c614..d00ea265dcb 100755 --- a/scripts/start-spiget +++ b/scripts/start-spiget @@ -88,7 +88,7 @@ downloadResourceFromSpiget() { resource=${1?} tempDir="/data/plugins/tmp-${resource}" - mkdir $tempDir + mkdir -p $tempDir resourceUrl="https://api.spiget.org/v2/resources/${resource}" if ! outfile=$(get_silent --output-filename -o $tempDir "${acceptArgs[@]}" "${resourceUrl}/download"); then log "ERROR: failed to download resource '${resource}' from ${resourceUrl}/download"