diff --git a/fs/torrentfs.go b/fs/torrentfs.go index aaaf1569..abe06512 100644 --- a/fs/torrentfs.go +++ b/fs/torrentfs.go @@ -67,7 +67,7 @@ type fileNode struct { TorrentOffset int64 } -func (fn fileNode) Attr() (attr fuse.Attr) { +func (fn fileNode) Attr(attr *fuse.Attr) { attr.Size = fn.size attr.Mode = defaultMode return @@ -232,7 +232,7 @@ func (dn dirNode) Lookup(ctx context.Context, name string) (_node fusefs.Node, e return } -func (dn dirNode) Attr() (attr fuse.Attr) { +func (dn dirNode) Attr(attr *fuse.Attr) { attr.Mode = os.ModeDir | defaultMode return } @@ -279,10 +279,8 @@ func (me rootNode) ReadDir(ctx context.Context) (dirents []fuse.Dirent, err erro return } -func (rootNode) Attr() fuse.Attr { - return fuse.Attr{ - Mode: os.ModeDir, - } +func (rootNode) Attr(attr *fuse.Attr) { + attr.Mode = os.ModeDir } // TODO(anacrolix): Why should rootNode implement this? diff --git a/fs/torrentfs_test.go b/fs/torrentfs_test.go index 7640dbb7..b5b7c637 100644 --- a/fs/torrentfs_test.go +++ b/fs/torrentfs_test.go @@ -230,12 +230,14 @@ func TestDownloadOnDemand(t *testing.T) { defer fs.Destroy() root, _ := fs.Root() node, _ := root.(fusefs.NodeStringLookuper).Lookup(context.Background(), "greeting") - size := int(node.Attr().Size) + var attr fuse.Attr + node.Attr(&attr) + size := attr.Size resp := &fuse.ReadResponse{ Data: make([]byte, size), } node.(fusefs.HandleReader).Read(context.Background(), &fuse.ReadRequest{ - Size: size, + Size: int(size), }, resp) content := resp.Data if string(content) != testutil.GreetingFileContents {