Fix mrpacktool.sh

If wget couldn't download a file from the provided url, the script would
continue anyway and jq would write over modrinth.index.json with an
empty file
This commit is contained in:
Sergeant Acoustic 2026-02-03 23:07:45 +00:00
parent 2edfc15844
commit 31225dfdf0

View file

@ -29,10 +29,17 @@ function urldecode() {
# Get file name from url trimmed by slash and url decoded
mod_file="$(urldecode ${mod_url##*/})"
trap "rm ${mods_dir}/${mod_file}" HUP INT TERM EXIT
trap "rm \"${mods_dir}/${mod_file}\"" HUP INT TERM EXIT
echo "Downloading file..."
wget -N --no-verbose --directory-prefix "$mods_dir" "$mod_url"
# Exit if download failed
if [ $? != "0" ]; then
echo "$0: Could not download mod from provided URL"
trap "" HUP INT TERM EXIT # Unset trap as there's no file to delete
exit 1
fi
# Collect data required by modrinth.index.json
echo "Processing file info"
mod_path="${mods_dir}/${mod_file}"