Commit bc15e4ef authored by Vitaly Lipatov's avatar Vitaly Lipatov

eget: add ipfs_get_real_url and use it for gateway mode

parent 0a690895
...@@ -626,14 +626,19 @@ elif [ "$ipfs_mode" = "local" ] ; then ...@@ -626,14 +626,19 @@ elif [ "$ipfs_mode" = "local" ] ; then
elif [ "$ipfs_mode" = "gateway" ] ; then elif [ "$ipfs_mode" = "gateway" ] ; then
info "Will use eget $IPFS_GATEWAY/HASH" info "Will use eget $IPFS_GATEWAY/HASH"
ipfs_get()
ipfs_get_real_url()
{ {
[ -n "$IPFS_GATEWAY" ] || fatal "ipfs http gateway is not set" [ -n "$IPFS_GATEWAY" ] || fatal "ipfs http gateway is not set"
# FIXME: echo "$IPFS_GATEWAY/$1"
}
ipfs_get()
{
if [ -n "$2" ] ; then if [ -n "$2" ] ; then
docmd eget -O "$2" "$IPFS_GATEWAY/$1" docmd eget -O "$2" "$(ipfs_get_real_url "$1")"
else else
docmd eget "$IPFS_GATEWAY/$1" docmd eget "$(ipfs_get_real_url "$1")"
fi fi
} }
...@@ -655,6 +660,11 @@ fi ...@@ -655,6 +660,11 @@ fi
if [ -n "$IPFS_CMD" ] ; then if [ -n "$IPFS_CMD" ] ; then
ipfs_get_real_url()
{
return 1
}
ipfs_get() ipfs_get()
{ {
[ -n "$IPFS_CMD" ] || fatal "ipfs api is not usable" [ -n "$IPFS_CMD" ] || fatal "ipfs api is not usable"
...@@ -826,6 +836,8 @@ url_get_real_url() ...@@ -826,6 +836,8 @@ url_get_real_url()
{ {
local URL="$1" local URL="$1"
local CID="$(cid_from_url "$URL")" local CID="$(cid_from_url "$URL")"
# if we use gateway, return URL with gateway
ipfs_get_real_url "$URL" && return
get_url_by_cid "$CID" get_url_by_cid "$CID"
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment