unixfs: remove `Get` prefix from `FSNode` accessors
See https://golang.org/doc/effective_go.html#Getters. License: MIT Signed-off-by: Lucas Molas <schomatis@gmail.com>
Lucas Molas committed
Jul 6, 2018 at 13:22 UTC
18361d38496228a40a72226ea4213cb0bf01bde3
7 files changed
+18
-18
importer/helpers/helpers.go
+1
-1
@@ -77,7 +77,7 @@ func (n *UnixfsNode) Set(other *UnixfsNode) {
77
n.raw = other.raw
78
n.rawnode = other.rawnode
79
if other.ufmt != nil {
80
- n.ufmt.SetData(other.ufmt.GetData())
80
+ n.ufmt.SetData(other.ufmt.Data())
81
}
82
}
83
mfs/file.go
+1
-1
@@ -60,7 +60,7 @@ func (fi *File) Open(flags int, sync bool) (FileDescriptor, error) {
60
return nil, err
61
}
62
63
- switch fsn.GetType() {
63
+ switch fsn.Type() {
64
default:
65
return nil, fmt.Errorf("unsupported fsnode type for 'file'")
66
case ft.TSymlink:
mfs/mfs_test.go
+1
-1
@@ -852,7 +852,7 @@ func TestFlushing(t *testing.T) {
852
t.Fatal(err)
853
}
854
855
- if fsnode.GetType() != ft.TDirectory {
855
+ if fsnode.Type() != ft.TDirectory {
856
t.Fatal("root wasnt a directory")
857
}
858
unixfs/archive/tar/writer.go
+2
-2
@@ -78,7 +78,7 @@ func (w *Writer) WriteNode(nd ipld.Node, fpath string) error {
78
return err
79
}
80
81
- switch fsNode.GetType() {
81
+ switch fsNode.Type() {
82
case upb.Data_Metadata:
83
fallthrough
84
case upb.Data_Directory, upb.Data_HAMTShard:
@@ -88,7 +88,7 @@ func (w *Writer) WriteNode(nd ipld.Node, fpath string) error {
88
case upb.Data_File:
89
return w.writeFile(nd, fsNode, fpath)
90
case upb.Data_Symlink:
91
- return writeSymlinkHeader(w.TarW, string(fsNode.GetData()), fpath)
91
+ return writeSymlinkHeader(w.TarW, string(fsNode.Data()), fpath)
92
default:
93
return ft.ErrUnrecognizedType
94
}
unixfs/io/dagreader.go
+1
-1
@@ -49,7 +49,7 @@ func NewDagReader(ctx context.Context, n ipld.Node, serv ipld.NodeGetter) (DagRe
49
return nil, err
50
}
51
52
- switch fsNode.GetType() {
52
+ switch fsNode.Type() {
53
case ftpb.Data_Directory, ftpb.Data_HAMTShard:
54
// Dont allow reading directories
55
return nil, ErrIsDir
unixfs/io/pbdagreader.go
+7
-7
@@ -52,7 +52,7 @@ func NewPBFileReader(ctx context.Context, n *mdag.ProtoNode, file *ft.FSNode, se
52
curLinks := getLinkCids(n)
53
return &PBDagReader{
54
serv: serv,
55
- buf: NewBufDagReader(file.GetData()),
55
+ buf: NewBufDagReader(file.Data()),
56
promises: make([]*ipld.NodePromise, len(curLinks)),
57
links: curLinks,
58
ctx: fctx,
@@ -105,7 +105,7 @@ func (dr *PBDagReader) precalcNextBuf(ctx context.Context) error {
105
return fmt.Errorf("incorrectly formatted protobuf: %s", err)
106
}
107
108
- switch fsNode.GetType() {
108
+ switch fsNode.Type() {
109
case ftpb.Data_Directory, ftpb.Data_HAMTShard:
110
// A directory should not exist within a file
111
return ft.ErrInvalidDirLocation
@@ -113,7 +113,7 @@ func (dr *PBDagReader) precalcNextBuf(ctx context.Context) error {
113
dr.buf = NewPBFileReader(dr.ctx, nxt, fsNode, dr.serv)
114
return nil
115
case ftpb.Data_Raw:
116
- dr.buf = NewBufDagReader(fsNode.GetData())
116
+ dr.buf = NewBufDagReader(fsNode.Data())
117
return nil
118
case ftpb.Data_Metadata:
119
return errors.New("shouldnt have had metadata object inside file")
@@ -240,12 +240,12 @@ func (dr *PBDagReader) Seek(offset int64, whence int) (int64, error) {
240
241
// left represents the number of bytes remaining to seek to (from beginning)
242
left := offset
243
- if int64(len(dr.file.GetData())) >= offset {
243
+ if int64(len(dr.file.Data())) >= offset {
244
// Close current buf to close potential child dagreader
245
if dr.buf != nil {
246
dr.buf.Close()
247
}
248
- dr.buf = NewBufDagReader(dr.file.GetData()[offset:])
248
+ dr.buf = NewBufDagReader(dr.file.Data()[offset:])
249
250
// start reading links from the beginning
251
dr.linkPosition = 0
@@ -254,7 +254,7 @@ func (dr *PBDagReader) Seek(offset int64, whence int) (int64, error) {
254
}
255
256
// skip past root block data
257
- left -= int64(len(dr.file.GetData()))
257
+ left -= int64(len(dr.file.Data()))
258
259
// iterate through links and find where we need to be
260
for i := 0; i < dr.file.NumChildren(); i++ {
@@ -301,7 +301,7 @@ func (dr *PBDagReader) Seek(offset int64, whence int) (int64, error) {
301
// for this seems to be good(-enough) solution as it's only returned by
302
// precalcNextBuf when we step out of file range.
303
// This is needed for gateway to function properly
304
- if err == io.EOF && dr.file.GetType() == ftpb.Data_File {
304
+ if err == io.EOF && dr.file.Type() == ftpb.Data_File {
305
return -1, nil
306
}
307
return n, err
unixfs/unixfs.go
+5
-5
@@ -217,15 +217,15 @@ func (n *FSNode) NumChildren() int {
217
return len(n.format.Blocksizes)
218
}
219
220
-// GetData retrieves the `Data` field from the internal `format`.
221
-func (n *FSNode) GetData() []byte {
220
+// Data retrieves the `Data` field from the internal `format`.
221
+func (n *FSNode) Data() []byte {
222
return n.format.GetData()
223
}
224
225
// SetData sets the `Data` field from the internal `format`
226
// updating its `Filesize`.
227
func (n *FSNode) SetData(newData []byte) {
228
- n.UpdateFilesize(int64(len(newData) - len(n.GetData())))
228
+ n.UpdateFilesize(int64(len(newData) - len(n.Data())))
229
n.format.Data = newData
230
}
231
@@ -237,8 +237,8 @@ func (n *FSNode) UpdateFilesize(filesizeDiff int64) {
237
int64(n.format.GetFilesize()) + filesizeDiff))
238
}
239
240
-// GetType retrieves the `Type` field from the internal `format`.
241
-func (n *FSNode) GetType() pb.Data_DataType {
240
+// Type retrieves the `Type` field from the internal `format`.
241
+func (n *FSNode) Type() pb.Data_DataType {
242
return n.format.GetType()
243
}
244