Commit 380d6725 authored by Vitaly Lipatov's avatar Vitaly Lipatov

eget: use timeout only for diag access

parent f97e31af
...@@ -423,7 +423,7 @@ done ...@@ -423,7 +423,7 @@ done
# defaults # defaults
# https://github.com/ipfs/kubo/issues/5541 # https://github.com/ipfs/kubo/issues/5541
ipfs_timeout='--timeout 10s' ipfs_diag_timeout='--timeout 10s'
ipfs_api_local="/ip4/127.0.0.1/tcp/5001" ipfs_api_local="/ip4/127.0.0.1/tcp/5001"
[ -n "$EGET_IPFS_API" ] && ipfs_api_local="$EGET_IPFS_API" [ -n "$EGET_IPFS_API" ] && ipfs_api_local="$EGET_IPFS_API"
...@@ -447,13 +447,13 @@ get_ipfs_brave() ...@@ -447,13 +447,13 @@ get_ipfs_brave()
ipfs_access() ipfs_access()
{ {
[ -n "$IPFS_CMD" ] || fatal "IPFS is disabled" [ -n "$IPFS_CMD" ] || fatal "IPFS is disabled"
$IPFS_CMD --api $IPFS_API $ipfs_timeout diag sys >/dev/null 2>/dev/null $IPFS_CMD --api $IPFS_API $ipfs_diag_timeout diag sys >/dev/null 2>/dev/null
} }
ipfs_check() ipfs_check()
{ {
[ -n "$IPFS_CMD" ] || fatal "IPFS is disabled" [ -n "$IPFS_CMD" ] || fatal "IPFS is disabled"
$IPFS_CMD --api $IPFS_API $ipfs_timeout cat "$1" >/dev/null $IPFS_CMD --api $IPFS_API $ipfs_diag_timeout cat "$1" >/dev/null
} }
...@@ -461,7 +461,8 @@ ipfs_check() ...@@ -461,7 +461,8 @@ ipfs_check()
select_ipfs_mode() select_ipfs_mode()
{ {
IPFS_CMD="$(get_ipfs_brave)" IPFS_CMD="$(get_ipfs_brave)"
if [ -n "$IPFS_CMD" ] ; then # if no EGET_IPFS_API, check brave
if [ -z "$EGET_IPFS_API" ] && [ -n "$IPFS_CMD" ] ; then
IPFS_API="$ipfs_api_brave" IPFS_API="$ipfs_api_brave"
if ipfs_access ; then if ipfs_access ; then
if ipfs_check "$ipfs_checkQm" ; then if ipfs_check "$ipfs_checkQm" ; then
...@@ -585,14 +586,17 @@ elif [ "$ipfs_mode" = "brave" ] ; then ...@@ -585,14 +586,17 @@ elif [ "$ipfs_mode" = "brave" ] ; then
IPFS_PRETTY_CMD="~Brave-Browser/$(basename $IPFS_CMD)" IPFS_PRETTY_CMD="~Brave-Browser/$(basename $IPFS_CMD)"
IPFS_API="$ipfs_api_brave" IPFS_API="$ipfs_api_brave"
ipfs_access || fatal "Can't access to Brave IPFS API (Brave browser is not running and IPFS is not activated?)" ipfs_access || fatal "Can't access to Brave IPFS API (Brave browser is not running and IPFS is not activated?)"
info "Will use $IPFS_PRETTY_CMD --api $IPFS_API"
elif [ "$ipfs_mode" = "local" ] ; then elif [ "$ipfs_mode" = "local" ] ; then
IPFS_CMD="$(print_command_path ipfs)" || fatal "Can't find ipfs command" IPFS_CMD="$(print_command_path ipfs)" || fatal "Can't find ipfs command"
IPFS_PRETTY_CMD="$IPFS_CMD" IPFS_PRETTY_CMD="$IPFS_CMD"
IPFS_API="$ipfs_api_local" IPFS_API="$ipfs_api_local"
ipfs_access || fatal "Can't access to IPFS API (ipfs daemon is not running?)" ipfs_access || fatal "Can't access to IPFS API (ipfs daemon is not running?)"
info "Will use $IPFS_PRETTY_CMD --api $IPFS_API"
elif [ "$ipfs_mode" = "gateway" ] ; then elif [ "$ipfs_mode" = "gateway" ] ; then
info "Will use eget $IPFS_GATEWAY/HASH"
ipfs_get() ipfs_get()
{ {
[ -n "$IPFS_GATEWAY" ] || fatal "ipfs http gateway is not set" [ -n "$IPFS_GATEWAY" ] || fatal "ipfs http gateway is not set"
...@@ -626,11 +630,11 @@ ipfs_get() ...@@ -626,11 +630,11 @@ ipfs_get()
{ {
[ -n "$IPFS_CMD" ] || fatal "ipfs api is not usable" [ -n "$IPFS_CMD" ] || fatal "ipfs api is not usable"
if [ -n "$2" ] ; then if [ -n "$2" ] ; then
showcmd $IPFS_PRETTY_CMD --api $IPFS_API $ipfs_timeout get -o "$2" "$1" showcmd $IPFS_PRETTY_CMD --api $IPFS_API get -o "$2" "$1"
$IPFS_CMD --api $IPFS_API $ipfs_timeout get -o "$2" "$1" $IPFS_CMD --api $IPFS_API get -o "$2" "$1"
else else
showcmd $IPFS_PRETTY_CMD --api $IPFS_API $ipfs_timeout get "$1" showcmd $IPFS_PRETTY_CMD --api $IPFS_API get "$1"
$IPFS_CMD --api $IPFS_API $ipfs_timeout get "$1" $IPFS_CMD --api $IPFS_API get "$1"
fi fi
} }
...@@ -659,8 +663,8 @@ ipfs_put() ...@@ -659,8 +663,8 @@ ipfs_put()
ipfs_cat() ipfs_cat()
{ {
[ -n "$IPFS_CMD" ] || fatal "ipfs api is not usable" [ -n "$IPFS_CMD" ] || fatal "ipfs api is not usable"
showcmd $IPFS_PRETTY_CMD --api $IPFS_API $ipfs_timeout cat "$1" showcmd $IPFS_PRETTY_CMD --api $IPFS_API cat "$1"
$IPFS_CMD --api $IPFS_API $ipfs_timeout cat "$1" $IPFS_CMD --api $IPFS_API cat "$1"
} }
fi fi
......
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