Commit af5b9c6a authored by Vitaly Lipatov's avatar Vitaly Lipatov

eget: implement --get-real-url

parent a39445ea
......@@ -509,6 +509,13 @@ get_filename_by_cid()
grep -F " $CID " "$EGET_IPFS_DB" | head -n1 | cut -f3 -d" "
}
get_url_by_cid()
{
local CID="$1"
[ -z "$EGET_IPFS_DB" ] && echo "$CID" && return
grep -F " $CID " "$EGET_IPFS_DB" | head -n1 | cut -f1 -d" "
}
else
EGET_IPFS_DB=''
......@@ -787,6 +794,7 @@ url_get_filename()
basename "$(url_get_real_url "$URL")"
}
else
CURL="$(print_command_path curl)"
[ -n "$CURL" ] || fatal "There are no wget nor curl in the system. Install it with $ epm install curl"
......@@ -919,6 +927,7 @@ scat()
put_cid_and_url "$URL" "$CID" "$FN"
}
# download to default name of to $2
sget()
{
......@@ -950,6 +959,11 @@ sget()
exit
fi
if [ -n "$GETREALURL" ] ; then
get_url_by_cid "$CID"
exit
fi
if [ -z "$TARGET" ] ; then
TARGET="$(get_filename_by_cid "$CID")"
if [ -z "$TARGET" ] ; then
......@@ -1019,6 +1033,11 @@ sget()
exit
fi
if [ -n "$GETREALURL" ] ; then
get_real_url "$1"
exit
fi
url_sget "$@"
}
......
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