'Generic Commit'
Some checks failed
Build-Test-Publish / build (push) Failing after 57s

This commit is contained in:
Your Name 2025-06-01 23:40:30 +12:00
parent da82558722
commit b75f29b39b

23
sos/sos
View File

@ -9,6 +9,14 @@ set -euo pipefail
# this will upload the file to the server, and return the download URL
# get dropshell
TEMP_DIR=$(mktemp -d)
curl -L -s -o "${TEMP_DIR}/dropshell" "https://getbin.xyz/dropshell"
chmod +x "${TEMP_DIR}/dropshell"
trap 'rm -rf "${TEMP_DIR}"' EXIT
DROPSHELL="${TEMP_DIR}/dropshell"
function show_help() {
cat << EOF
@ -93,11 +101,24 @@ EOF
WRITE_TOKEN=$(cat "$TOKENPATH")
fi
# trip whitespace from the file path
LOCALHASH=$("${DROPSHELL}" hash "${FILEPATH}" | tr -d '[:space:]')
echo "Local hash: $LOCALHASH"
FILELINE="-F \"file=@${file}\""
EXISTSJSON=$(eval "curl -s \"https://$server/exists/$LOCALHASH\"")
DOESEXIT=$(echo "$EXISTSJSON" | jq -r '.exists')
if [ "$DOESEXIT" == "true" ]; then
echo "File already exists, skipping upload"
FILELINE=""
fi
HASH=""
# shellcheck disable=SC2086
curl --progress-bar -X PUT \
-H "Authorization: Bearer ${WRITE_TOKEN}" \
-F "file=@${file}" \
$FILELINE \
-F "metadata=${METADATA_JSON}" \
"$TARGET_URL" \
|| die "Failed to upload $file to $TARGET_URL"