Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
eb92eee1
Commit
eb92eee1
authored
Apr 10, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eget: rewrite download for IPFS
parent
a0aff9ad
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
6 deletions
+30
-6
tools_eget
bin/tools_eget
+30
-6
No files found.
bin/tools_eget
View file @
eb92eee1
...
@@ -622,8 +622,23 @@ ipfs_get()
...
@@ -622,8 +622,23 @@ ipfs_get()
ipfs_put
()
ipfs_put
()
{
{
[
-n
"
$IPFS_CMD
"
]
||
fatal
"ipfs api is not usable"
[
-n
"
$IPFS_CMD
"
]
||
fatal
"ipfs api is not usable"
# detect if -q is used (will output Qm instead of addded Qm)
local
qu
=
"
$1
"
[
"
$qu
"
=
"-q"
]
||
qu
=
''
showcmd
$IPFS_PRETTY_CMD
--api
$IPFS_API
add
"
$@
"
showcmd
$IPFS_PRETTY_CMD
--api
$IPFS_API
add
"
$@
"
$IPFS_CMD
--api
$IPFS_API
add
"
$@
"
local
res
res
=
"
$(
$IPFS_CMD
--api
$IPFS_API
add
"
$@
"
)
"
||
return
if
[
-z
"
$qu
"
]
;
then
res
=
"
$(
echo
"
$res
"
|
grep
"^added Qm"
)
"
||
return
res
=
"
$(
echo
"
$res
"
|
cut
-f2
-d
" "
)
"
fi
is_ipfs_hash
"
$res
"
&&
echo
"
$res
"
&&
return
fatal
"Can't recognize
$res
IPFS hash"
}
}
ipfs_cat
()
ipfs_cat
()
...
@@ -996,30 +1011,39 @@ sget()
...
@@ -996,30 +1011,39 @@ sget()
fi
fi
if
[
-z
"
$TARGET
"
]
;
then
if
[
-z
"
$TARGET
"
]
;
then
# TODO: in some cases we can get name from URL...
TARGET
=
"
$(
get_filename_by_cid
"
$CID
"
)
"
TARGET
=
"
$(
get_filename_by_cid
"
$CID
"
)
"
if
[
-z
"
$TARGET
"
]
;
then
if
[
-z
"
$TARGET
"
]
;
then
TARGET
=
"
$CID
"
TARGET
=
"
$CID
"
fi
fi
fi
fi
[
"
$URL
"
=
"
$REALURL
"
]
&&
info
"
$URL
->
$CID
->
$TARGET
"
||
info
"
$URL
->
$REALURL
->
$CID
->
$TARGET
"
[
"
$URL
"
=
"
$REALURL
"
]
&&
info
"
$URL
->
$CID
->
$TARGET
"
||
info
"
$URL
->
$REALURL
->
$CID
->
$TARGET
"
ipfs_get
"
$CID
"
"
$TARGET
"
ipfs_get
"
$CID
"
"
$TARGET
"
&&
return
# fail get from IPFS, fallback
url_sget
"
$REALURL
"
"
$TARGET
"
return
return
fi
fi
# download and put to IPFS
local
FN
=
"
$(
url_get_filename
"
$REALURL
"
)
"
||
return
local
FN
=
"
$(
url_get_filename
"
$REALURL
"
)
"
||
return
if
[
-z
"
$TARGET
"
]
;
then
if
[
-z
"
$TARGET
"
]
;
then
TARGET
=
"
$FN
"
TARGET
=
"
$FN
"
fi
fi
CID
=
"
$(
download_to_ipfs
"
$REALURL
"
)
"
||
return
if
[
-n
"
$GETIPFSCID
"
]
;
then
if
[
-n
"
$GETIPFSCID
"
]
;
then
put_cid_and_url
"
$REALURL
"
"
$CID
"
"
$FN
"
# add to IPFS and print out CID
CID
=
"
$(
ipfs_put
"
$REALURL
"
)
"
||
return
echo
"
$CID
"
echo
"
$CID
"
exit
exit
fi
fi
ipfs_get
"
$CID
"
"
$TARGET
"
||
return
# download file and add to IPFS
url_sget
"
$REALURL
"
"
$TARGET
"
||
return
CID
=
"
$(
ipfs_put
"
$TARGET
"
)
"
||
return
is_ipfs_hash
"
$CID
"
||
return
put_cid_and_url
"
$REALURL
"
"
$CID
"
"
$FN
"
put_cid_and_url
"
$REALURL
"
"
$CID
"
"
$FN
"
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment