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

ipfs files cp: report which file doesn't exist #5088

Closed
schomatis opened this issue Jun 6, 2018 · 2 comments
Closed

ipfs files cp: report which file doesn't exist #5088

schomatis opened this issue Jun 6, 2018 · 2 comments
Assignees
Labels
topic/files Topic files topic/technical debt Topic technical debt

Comments

@schomatis
Copy link
Contributor

In the case of copying a file in MFS I would like to know which of the two files doesn't exist, as the Unix cp command would report it (this also applies to moving files and similar commands).

cp /this-path-doesnt-exist /this-one-either
# cp: cannot stat '/this-path-doesnt-exist': No such file or directory

ipfs files cp /this-path-doesnt-exist /this-one-either
# Error: file does not exist
# (Which one?)

From the code I would think the most direct way is just to wrap the errors that return from getNodeFromPath and PutNode (that will fail in the Directory.Find() call) with the name of either the src or dst path, but maybe the error should be handled deeper inside the code.

https://github.com/ipfs/go-ipfs/blob/7853e53860805e08a212d78c4baa5d59bff99ba8/core/commands/files.go#L330-L340

(Ideally I would even like to specify which part of the path doesn't exist, but this is probably going to far.)

@Stebalien WDYT

@schomatis schomatis added topic/files Topic files topic/technical debt Topic technical debt labels Jun 6, 2018
@schomatis schomatis added this to the Files API Documentation milestone Jun 6, 2018
@schomatis schomatis self-assigned this Jun 6, 2018
@kevina
Copy link
Contributor

kevina commented Jun 6, 2018

Our error reporting in general sucks.

@Stebalien
Copy link
Member

So, cp actually does this at the top level. If we were mimicking it, we'd do it right before calling SetError in the command.

The most general solution would be to have DirLookup and PutNode wrap the error in an os.PathError. However, that won't cover the /ipfs/ special case... (I wish we handled this within MFS instead of within the command)

So yeah, your solution sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/files Topic files topic/technical debt Topic technical debt
Projects
None yet
Development

No branches or pull requests

3 participants