-
Notifications
You must be signed in to change notification settings - Fork 200
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
client: add support for nocopy, raw-leaves to add method #159
client: add support for nocopy, raw-leaves to add method #159
Conversation
I believe that the target branch should be |
f40b70f
to
44aee5f
Compare
Ok. Rebased and re-tested. |
Looks good and I'd love to just merge this. However… Two things:
|
826799e
to
530b8bc
Compare
Note that server is still broken: it does not return an error if the path is invalid, it again silently ignores nocopy and adds to blockstore in this case. Also note that, relative paths are invalid (neither relative to server user home nor relative to working dir of server is works), despite paths in the filestore being recorded relative to the user home. ipfs/kubo#5987 Finally note that adding a file with nocopy whose blocks happen to already be in the blockstore, is going to succeed, but those blocks won't be (also) added to the filestore, they won't be listed as duplicates by
|
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.
One tiny thing regarding the tests only: We try to leave the daemon in a similar state after the tests as when it was started, so you need to add the relevant fixtures to your tests.
Thank you for this submission!
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.
… and the CI will of course need to be made happy again. I added some comments about specifics, but you'll also need to:
- Rebase onto latest
py-ipfs-http-client
to make timeouts on Python 3.5+ go away (my mistake)- GIT commands:
git remote add upstream https://github.com/ipfs/py-ipfs-api.git; git fetch upstream py-ipfs-http-client && git rebase upstream/py-ipfs-http-client
- GIT commands:
- Fix the code style issues (run
tox -e codestyle
to see)
Again, thanks for your contribution!
Use r'' when defining literals that form a regular expression. Fixes warning about invalid escape characters, like \S.
./ipfshttpclient/multipart.py:362: DeprecationWarning: Flags not at the start of the expression '^.*\\Z(?ms)$'
This header is required for adding files by reference, i.e. adding into the filestore via the add command with nocopy=True option. We can't unconditionally add the header, because we don't always have the path to the file (e.g. not when the caller of add() passes us a file descriptor only). Unconditionally adding a header with a blank value does not seem good. We only append the Abspath header if we have a path and if it is an absolute path. Note that Abspath value must be an absolute path -- the nocopy option only makes sense with an absolute path. Regardless of this client side decision for when to append the header, though, the server should return an error if a relative path or a non-existant path is passed in Abspath. At the very least, it should return an error nocopy is passed with a relative path or non-existant path or a path outside of the daemon's working directory. Currently, the server does NOT return an error, instead it silently ignores nocopy and adds the file to the blockstore instead -- this is a bug. Luckily, the server does return an error if nocopy is passed but Abspath header was not set. The client-side logic described above reduces the case of nocopy with relative path to nocopy without Abspath header, and thus the caller will get an error in all cases.
The nocopy command is for adding files by reference to their location in the filesystem. The nocopy implies raw-leaves. Requires bug fix in go-ipfs 77cd41a (see issue #4558), ver >0.4.18 (strictly greater). The nocopy option implies raw-leaves, and the default for raw-leaves depends on nocopy. This dynamic default is the behavior of the HTTP API tested via curl. Adding files to the filestore via nocopy requires that the path is absolute, not relative. The multipart stream component appens the Abspath header when it has the absolute path to the file. In IPFS daemon used for tests, enable the filestore feature. The tests could leverage the filestore API, but that part of the API is not yet implemented, so leaving parts of the test commented out.
Requires go-ipfs patch that is not yet released. Please revert this commit when the cited commit makes it into the release and the go-ipfs on buildbots for ipfsapi is updated.
Ok, applied all the fixes. Thanks for specific patches. Also, skipped the test that tests the error path. Please revert the last commit when go-ipfs is updated. |
@radfish: Thank you! This looks perfect! 😁 |
nocopy is accessible form the CLI, so let's make it accessible from API as well.