-
-
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
Reported directory size always 0 #4580
Comments
@Stebalien Is this a relevant issue to work on? The help message from
But from what I'm seeing debugging the code the reconstructed |
@schomatis I'd love to, but as of now they are not functionally equivalent. For one, Example output {
"Objects": [
{
"Hash": "/ipfs/QmYcutogfHrrxigzVw2Vi8P1cdiuXNn9VecL9cy95wB9MP",
"Links": [
{
"Name": "reindex",
"Hash": "Qmac74sj9SgTVVVHFgWrFL6wyUQ8k8sgK4LYcEPTNoz3jW",
"Size": 18132,
"Type": 1
}
]
}
]
} Related: #3081 |
The problem seems to be the way in which the root object size is obtained. Normally the size of the directory is obtained from its parent's link size, but the root directory doesn't have a parent with that information.
In the second listing the size of the Later in the code the child nodes ( |
So, @schomatis, if you'd like to fix this, go ahead. Your diagnosis sounds correct. edit: apparently, I need to pay more attention. We do include the type, we just return it as a number instead of as as string (for some unknown reason...). |
@Stebalien Note that by removing the existing types in listings, as with I really think there should be some abstraction in the API/command line of IPFS to figure out what kind of information we're dealing with. It doesn't need to be in the Lastly; as, currently, the 'file type' of an object is in the first 2 bytes of the object, where do you see an unacceptable performance impact on the Context: $ ipfs object get /ipfs/QmYcutogfHrrxigzVw2Vi8P1cdiuXNn9VecL9cy95wB9M {
"Links": [
{
"Name": "reindex",
"Hash": "Qmac74sj9SgTVVVHFgWrFL6wyUQ8k8sgK4LYcEPTNoz3jW",
"Size": 18132
}
],
"Data": "\b\u0001"
} |
The problem is that you have to actually fetch the object. Listing the names in a directory requires only fetching the directory object. Listing the types as well requires fetching both the directory and the root block of all of the files in the directory. However, we should probably have some kind of Note: we do actually have a stat you can use: Also note: I agree that not having a decent |
I'm not sure what the fix should be. I can copy the My main confusion here stems from the fact that I have trouble discerning when are we talking about the size of a unix file or the size of the underlying node structure that represents it. @dokterbob Is the |
@schomatis I would really love the |
As a note, |
There are three options: 1. nothing 2. underlying node 3. resolve file nodes and sum their |
@Kubuxu Well, number 1 is what started this issue in the first place, so I'll go with number 2, thanks. |
That case I would suggest going for 2 AND documenting it too!
In a sense undefined behavior is part of the problem here.
HOWEVER, currently it displays the cumulative size for subdirectories AFAIK. Wouldn't it then make sense to do the same for the directory itself? (As in, recursive consistency.)
In any case, the cumulative size seems more practically useful to me; I find it hard to imagine a use case for knowing the directory node size.
--
Verstuurd vanaf mijn Android apparaat met K-9 Mail. Excuseer mijn beknoptheid.
|
Yes. Actually, in the
Yes, to honor the unix API I'll have to list in both cases the underlying node's size.
Agreed, please open another issue to discuss the possibility of adding another flag to this command to list cumulative sizes (or maybe the addition of a |
Thanks for your reply!
> In any case, the cumulative size seems more practically useful to me; I find it hard to imagine a use case for knowing the directory node size.
Agreed, please open another issue to discuss the possibility of adding another flag to this command to list cumulative sizes (or maybe the addition of a du command).
Note that this is also what the web interface currently does.
|
So my edit doesn't get lost in the noise, I read your comments about including the type as "the type is missing" not "the type is an int". Apparently, we do return the type (and do take the performance hit of fetching the root nodes). Really, I don't see why this command returns a number instead of a string. |
I would really really love to have the cumulative size for directories available - just like the web interface. This is what users will be expecting and it gives a lot of actual information whereas the size of the actual node is very rarely ever relevant here. |
:) |
go-ipfs version: 0.4.13-
Repo version: 6
System version: amd64/linux
Golang version: go1.9.2
Type: Bug
Severity: Medium
Description:
The size of directories, returned from the API server, is always
0
- instead of the sum of the directory's contents.Example:
Result:
Expected size:
18132
, plus actual directory data (i.e. filenames).The text was updated successfully, but these errors were encountered: