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

CoreAPI: ObjectStat and DataSize #5325

Open
djdv opened this issue Aug 1, 2018 · 4 comments
Open

CoreAPI: ObjectStat and DataSize #5325

djdv opened this issue Aug 1, 2018 · 4 comments
Labels
kind/enhancement A net-new feature or improvement to an existing feature topic/core-api Topic core-api

Comments

@djdv
Copy link
Contributor

djdv commented Aug 1, 2018

When trying to migrate data out of IPFS with the CoreAPI, I noticed that an ObjectStat's DataSize member, is the size for the object's entire data segment, not just the size of the raw data stored under the type/format.
For example, current UnixFS nodes storing the data "IPFS", will be larger than 4bytes.

I believe adding a .RawDataSize member, would be valuable, for people who wish to migrate data out of IPFS.
It would allow them to consider the data segment's raw/target data size, and make decisions based around it, when dealing with foreign filesystems. For example, when dealing with file allocation sizes on an external drive of another format, prior to calling Cat().

My current workaround seems suboptimal: reference

Ping @magik6k, @schomatis

@djdv djdv added the topic/core-api Topic core-api label Aug 1, 2018
@schomatis
Copy link
Contributor

Yes, I think that rather than modify the ObjectAPI, is the UnixfsAPI that should be extended to get information regarding file size and similar (as the first deals only with the DAG layer and doesn't know that a file might be encoded inside of a DAG node, but the second one should).

@Stebalien
Copy link
Member

For context, the object API is for interacting with merkledag objects (it's not even generalized over all IPLD objects), which may not be unixfs nodes. Basically, all this API knows is that we have some "object" with a data field (raw bytes) and a links field (list of links).

Unfortunately, we don't really have a good "unixfs" equivalent, as fr as I know.

@Stebalien Stebalien added the kind/enhancement A net-new feature or improvement to an existing feature label Sep 10, 2018
@magik6k
Copy link
Member

magik6k commented Oct 18, 2018

I haven't verified this, but api.Unixfs().Get().(files.SizeFile).Size() should be returning the right size - https://github.com/ipfs/go-ipfs/blob/master/core/coreapi/unixfile.go#L122

@schomatis
Copy link
Contributor

Yes, going through the DagReader seems the correct way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A net-new feature or improvement to an existing feature topic/core-api Topic core-api
Projects
None yet
Development

No branches or pull requests

4 participants