Skip to content
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

Merged
merged 1 commit into from
Jan 7, 2019
Merged

fix: add by path #923

merged 1 commit into from
Jan 7, 2019

Conversation

fsdiogo
Copy link
Contributor

@fsdiogo fsdiogo commented Jan 4, 2019

Fixes #921.

@fsdiogo fsdiogo self-assigned this Jan 4, 2019
@ghost ghost added the status/in-progress In progress label Jan 4, 2019
Copy link
Member

@olizilla olizilla left a 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}`
Copy link
Member

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

see: https://github.com/ipfs-shipyard/ipld-explorer-components/blob/adceb5f6760cb88165d026b65fb38f491fb4f843/src/lib/parse-ipld-path.js

Copy link
Contributor Author

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:

https://github.com/ipfs-shipyard/ipfs-webui/blob/1e2c58fee899009cf68bc4c903d4eed9dbbe1f0b/src/files/file-input/ByPathModal.js#L14

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.

Copy link
Member

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?

Copy link
Member

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

see: https://github.com/ipfs/js-ipfs-mfs/blob/b4f6083557276650d030c7172b94a6847425f228/src/core/utils/to-mfs-path.js#L52

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

Copy link
Member

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.

Copy link
Member

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

@olizilla olizilla merged commit 040891f into master Jan 7, 2019
@olizilla olizilla deleted the fix/add-by-path branch January 7, 2019 10:05
@ghost ghost removed the status/in-progress In progress label Jan 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants