-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add by path #923
fix: add by path #923
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, I'm just wondering if we need to make it any more robust.
@@ -266,7 +266,8 @@ export default (opts = {}) => { | |||
doFilesAddPath: make(actions.ADD_BY_PATH, (ipfs, root, src) => { | |||
const name = src.split('/').pop() | |||
const dst = join(root, name) | |||
return ipfs.files.cp([src, dst]) | |||
const srcPath = src.startsWith('/') ? src : `/ipfs/${name}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What namespaces are supported here? can you add from an /ipns
path? We do more to normalise the user input in the ipld path explorer, which might be something worth extracting and reusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ipns
paths are not supported, as we are using:
See https://github.com/ipfs/is-ipfs#usage.
I agree this should be more robust, but if we want to enable ipns paths we'll have to resolve them to an ipfs cid and then add that path right?
One more thing, Add by path
uses ipfs.files.cp
to move stuff around. We should be able to add a CID directly of a file that isn't on our repo yet, I tried that the first time I saw Add by path
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the underlying IPFS API parse ipns paths? Or am I being a bit far fetched?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fsdiogo the first argument ot cp can be an ipfs address that isn't currently in your repo. You can copy in remote files.
# copy in the home page of arewedistributedyet.com into /awdy.html on local MFS
$ ipfs files cp /ipfs/QmeANzfbKFunvrenGDVbAttucJvNF6wrWH96QeSWdmgGy6/index.html /awdy.html
@hacdias looks like cp only supports MFS -> MFS and /ipfs -> MFS copying... js-ipfs-mfs only has a special case for paths that start with /ipfs
and go-ipfs from the command line fails on:
$ ipfs files cp /ipns/arewedistributedyet.com/index.html /awdy.html
Error: cp: cannot get node from path /ipns/arewedistributedyet.com/index.html: file does not exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we detect ´/ipns´ and call ipfs.dns? We could show an indicator so the user knows what's going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could do, but it sounds like something that we should push for support for in go/js-ipfs rather than working around it at the app layer
Fixes #921.