Browse Source

Merge tag 'v0.5.1' into develop

Fixup errors on unbound vars

* tag 'v0.5.1':
  Fix direct url adding by removing leftovers and changing to ipfs-add
tags/v0.5.2^2
Bèr Kessels 1 year ago
parent
commit
62de247464
1 changed files with 6 additions and 7 deletions
  1. 6
    7
      wget-to-ipfs.sh

+ 6
- 7
wget-to-ipfs.sh View File

@@ -148,7 +148,6 @@ function date_iso_8601() {
[[ "${__usage+x}" ]] || read -r -d '' __usage <<-'EOF' || true # exits non-zero when EOF encountered
-u --url [arg] URL to download. Required.
-r --root [arg] IPFS id of a directory to add the file to. Leave empty when you don't want to add the file to a directory.
-t --temp [arg] Location of tempfile. Default="/tmp/wget-to-ipfs"
-p --pinbook [arg] Location of the optional Pinfile where pinned hashes are stored.
-v Enable verbose mode, print script as it is executed
-d --debug Enables debug mode
@@ -325,7 +324,6 @@ fi
##############################################################################

function __b3bp_cleanup_before_exit () {
rm "${arg_t}"
info "Cleaning up. Done"
}
trap __b3bp_cleanup_before_exit EXIT
@@ -381,16 +379,17 @@ fi

_check_binary "ipfs"

_file_hash="$(ipfs urlstore add ${arg_u})"
info "Added ${_file_name} as ${_file_hash}"

_file_hash="$(ipfs add --nocopy --cid-version=1 --quieter ${arg_u})"
info "Added ${arg_u} as ${_file_hash}"

if [[ -n ${arg_p} ]]; then
echo "$(date_iso_8601) ${_file_hash} ${_arg_u}" >> ${arg_p}
echo "$(date_iso_8601) ${_file_hash} ${arg_u}" >> ${arg_p}
fi

if [[ -n ${arg_r} ]]; then
_new_dir="$(ipfs object patch ${arg_r} add-link $_file_name $_file_hash)"
info "Placed ${_file_name} in directory, new root is ${_new_dir}"
_new_dir="$(ipfs object patch ${arg_r} add-link $arg_u $_file_hash)"
info "Placed ${arg_u} in directory, new root is ${_new_dir}"
fi

echo "file: ${_file_hash}"

Loading…
Cancel
Save