Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Avoid use of pb.Data #17

Closed
overbool opened this issue Sep 20, 2018 · 6 comments
Closed

Avoid use of pb.Data #17

overbool opened this issue Sep 20, 2018 · 6 comments

Comments

@overbool
Copy link
Contributor

see ipfs/kubo#5217 (comment)

overbool added a commit to overbool/go-unixfs that referenced this issue Sep 20, 2018
@overbool
Copy link
Contributor Author

overbool commented Sep 20, 2018

@schomatis In order to use pb.Data's functions, I add Format() to receiver FSNode as follow:

// Format returns the format inside this node
func (n *FSNode) Format() *pb.Data {
	return &n.format
}

But, Format() is confusing or not so good.

WDYT?

@schomatis
Copy link
Contributor

Why would you need that? (I'm not sure I follow.) The idea behind FSNodeFromBytes was to avoid direct manipulation of pb.Data (and hence its format).

@overbool
Copy link
Contributor Author

it will call GetFilesize() somewhere that is a pb.Data function.

Did you mean that we could wrap the GetFilesize() or maybe other pb.Data functions to avoid direct manipulation of pb.Data.

just like:

func (n *FSNode) GetFilesize() uint64 {
	return n.format.GetFilesize()
}

overbool added a commit to overbool/go-unixfs that referenced this issue Sep 21, 2018
@schomatis
Copy link
Contributor

Did you mean that we could wrap the GetFilesize() or maybe other pb.Data functions to avoid direct manipulation of pb.Data.

Yes, because actually you wouldn't have pb.Data objects laying around in the code anymore, you would just have the FSNode type. However, if you see a case where we definitely need to use pb.Data please point me to it and we'll evaluate it.

@overbool
Copy link
Contributor Author

@schomatis ok, I misunderstood you at first。

in my own view, wrapping all pb.Data functions maybe is a good idea that we can absolutely avoid direct manipulation of pb.Data.

overbool added a commit to overbool/go-unixfs that referenced this issue Sep 21, 2018
overbool added a commit to overbool/go-unixfs that referenced this issue Sep 21, 2018
overbool added a commit to overbool/go-unixfs that referenced this issue Sep 23, 2018
Stebalien added a commit that referenced this issue Sep 24, 2018
@schomatis
Copy link
Contributor

Fixed in #18.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants