📦➔🦋 Store and retrieve files on the Atmosphere
at dev 30 lines 911 B view raw
1#!/usr/bin/env bash 2 3function atfile.delete() { 4 key="$1" 5 success=1 6 unset error 7 8 # shellcheck disable=SC2154 9 lock_record="$(com.atproto.repo.getRecord "$_username" "blue.zio.atfile.lock" "$key")" 10 11 if [[ $(echo "$lock_record" | jq -r ".value.lock") == true ]]; then 12 # shellcheck disable=SC2154 13 atfile.die "Unable to delete '$key' — file is locked\n Run \`$_prog unlock $key\` to unlock file" 14 fi 15 16 # shellcheck disable=SC2154 17 record="$(com.atproto.repo.deleteRecord "$_username" "$_nsid_upload" "$key")" 18 error="$(atfile.util.get_xrpc_error $? "$record")" 19 20 if [[ -z "$error" ]]; then 21 # shellcheck disable=SC2154 22 if [[ $_output_json == 1 ]]; then 23 echo "{ \"deleted\": true }" | jq 24 else 25 echo "Deleted: $key" 26 fi 27 else 28 atfile.die.xrpc_error "Unable to delete '$key'" "$error" 29 fi 30}