New logger with color and specific types. Code cleanup (#3108)

This commit is contained in:
Tristan
2024-10-22 23:04:38 +02:00
committed by GitHub
parent a356c6810e
commit bef7b4719f
38 changed files with 424 additions and 428 deletions

View File

@@ -57,7 +57,7 @@ getResourceFromSpiget() {
if [[ -n $(find "$versionfile" -mmin +${SPIGET_DOWNLOAD_TOLERANCE}) ]]; then
urlVersion="https://api.spiget.org/v2/resources/${resource}/versions/latest"
if ! get -o "${versionfileNew}" "${urlVersion}"; then
log "ERROR failed to download resource version meta data '${resource}' from ${urlVersion}"
logError "Failed to download resource version meta data '${resource}' from ${urlVersion}"
exit 2
fi
@@ -83,7 +83,7 @@ getResourceFromSpiget() {
if downloadResourceFromSpiget "${resource}"; then
urlVersion="https://api.spiget.org/v2/resources/${resource}/versions/latest"
if ! get -o "${versionfileNew}" "${urlVersion}"; then
log "ERROR failed to download resource version meta data '${resource}' from ${urlVersion}"
logError "Failed to download resource version meta data '${resource}' from ${urlVersion}"
exit 2
fi
mv "${versionfileNew}" "${versionfile}"
@@ -99,16 +99,16 @@ downloadResourceFromSpiget() {
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"
logError "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"
log " instead of using SPIGET_RESOURCES"
logError " Visit $externalUrl to pre-download the resource"
logError " instead of using SPIGET_RESOURCES"
fi
exit 1
fi
if ! fileType=$(get --json-path '.file.type' "${resourceUrl}"); then
log "ERROR: failed to retrieve file type of resource $resource"
logError "Failed to retrieve file type of resource $resource"
exit 1
fi
if [[ $fileType = .sk ]]; then
@@ -122,7 +122,7 @@ downloadResourceFromSpiget() {
log "Extracting contents of resource ${resource} into plugins"
extract "$outfile" /data/plugins
else
log "ERROR: file for resource ${resource} has an unexpected file type: ${fileType}"
logError "File for resource ${resource} has an unexpected file type: ${fileType}"
exit 2
fi
fi