-
-
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
Golint-ify unixfs module #4664
Golint-ify unixfs module #4664
Conversation
License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
Note, stuttering required renaming of HamtShard to Shard. License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
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.
Mostly LGTM.
unixfs/io/dirbuilder.go
Outdated
@@ -157,6 +162,9 @@ func (d *Directory) Links(ctx context.Context) ([]*ipld.Link, error) { | |||
return d.shard.EnumLinks(ctx) | |||
} | |||
|
|||
// Find returns the ipld.Node with the given name, if it is contained in this | |||
// directory. Find only searches in the most inmediate links, and not | |||
// recursively in the tree. | |||
func (d *Directory) Find(ctx context.Context, name string) (ipld.Node, error) { |
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.
Find returns the root node of the file named name
within this directory (really, it should be called Lookup
). It does, in fact, traverse the tree (when searching a hamt).
unixfs/mod/dagmodifier.go
Outdated
var ( | ||
ErrSeekFail = errors.New("failed to seek properly") | ||
ErrUnrecognizedWhence = errors.New("unrecognized whence") | ||
ErrNotUnixfs = fmt.Errorf("dagmodifier only supports unixfs nodes (proto or raw)") |
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.
Might as well be consistent and use the errors
package.
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.
out of scope I'd say
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.
ah, yeah, got it now
unixfs/io/bufdagreader.go
Outdated
func NewBufDagReader(b []byte) *bufDagReader { | ||
// newBufDagReader returns a DAG reader for the given byte slice. | ||
// BufDagReader is used to read RawNodes. | ||
func newBufDagReader(b []byte) *bufDagReader { |
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.
I'd just make bufDatReader
public.
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.
So between increasing the API surface and decreasing it, I went with the latter (since this method is not used by anyone). But I'll make it public then...
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.
Yeah, but you exposed the PBDagReader
so I figured we should be consistent at least.
License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
per @Stebalien's comment License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
unixfs/io/dagreader.go
Outdated
|
||
// A DagReader represents a ReadSeekCloser which offers additional methods |
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.
represents a ReadSeekCloser which offers additional methods
This doesnt really get at what the dagreader does. I would say something more like:
// A DagReader provides read-only read and seek acess to a unixfs file.
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.
Thanks
unixfs/io/dagreader.go
Outdated
type DagReader interface { | ||
ReadSeekCloser | ||
Size() uint64 | ||
CtxReadFull(context.Context, []byte) (int, error) | ||
Offset() int64 | ||
} | ||
|
||
// A ReadSeekCloser implements interfaces to read, write, seek and close. |
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.
'write' doesnt belong
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.
right, more copy
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.
Great stuff! just a couple small nitpicks, then LGTM
Per @whys suggestions License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
all comments addressed |
License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
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.
Woooo!
This resolves all golint warnings in
unixfs
.hamt.HamtShard
has been renamed tohamt.Shard
to remove stuttering.Note that protobuf generated files are not golint compliant, but haven't touched those.