-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 ls -l doesn't return hash or size when listing files directly #5044
Comments
From what I understand from reading the files API, there is important information (such as the hash and the size, and I'm not sure if the name also) that doesn't belong to the node that represents the file but rather to the directory that contains it, i.e., that has a link (to the file) where that information is actually stored. This means that there is some information that can only be obtained by querying the directory (AFAIK). |
The name, sure - that's stored on the DAGLink of the containing directory, but the hash and the block sizes of the data nodes are stored as part of the file node and you have to walk the tree to find out what hash |
Yes, so scratch most of my last comment, the This can be improved, I'll send a PR. |
@achingbrain Could you give #5045 a try to see how it feels? Keep in mind that the sizes reported by listing the directory and the file might vary by a small amount due to some metadata (ideally those sizes should be unified). |
I must be doing something wrong because I still see 0 for the file size and no hash. I did:
Sorry, I don't know much about go.. Is it going to print out the node size or the sum of the block sizes? |
Oh, sorry, the PR I pointed you to is not yet merged (nor it will be in the near future until I figure out the size discrepancies), the commands you're listing sound correct but I would recommend you try the official GitHub way which don't require to add my repo with the branch but to fetch it indirectly through the PR number (using the original ipfs remote):
It should print the node size plus the size of the blocks (links) its referencing. But that's what I want to be certain of before merging the PR. |
Aha, that's better - thanks. From what I can see, if something is a directory, it should have size 0, if it's a file, you should extract the UnixFS block sizes from the files' data block - the sum of which will give you the total size of the file without the proto-buf wrapper overhead. Otherwise ipfs disagrees with itself on what the file sizes are. E.g. with your PR changes:
|
Yes, I've modified the PR to get the size from the |
That's great, both invocations have the same file size now. |
Great, thanks for raising this issue and guiding me through it, it has been very illustrative. I'm cc'ing @Stebalien to make sure what we have been discussing makes any sense, if he approves I'll unblock the PR and it will be ready to merge. |
That sounds correct. Sorry, I hadn't realized the size bug had been resolved. That PR should be good to go (modulo the review nit). |
Closing this in favour of the PR that will resolve it: #5045 |
Hey @achingbrain, not a big deal but just to keep up with the convention allow me to keep this issue open until #5045 gets actually merged (when that happens the "Fixes" word in the PR comment will signal GitHub to automatically close this). |
Ok, sorry about that. Was just trying to not have redundant issues open. |
And, since I'm here, I'm including this issue in the milestone (just a symbolic thing, but this was the issue that motivated me to really learn about the Files API). |
Listing a directory shows hashes and sizes:
But if you list the file directly, extended information is not returned:
The text was updated successfully, but these errors were encountered: