Skip to content

Commit

Permalink
More megacheck
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed Nov 7, 2017
1 parent 9757f04 commit cecc70f
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 33 deletions.
3 changes: 1 addition & 2 deletions fs/file_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package torrentfs
import (
"context"
"io"
"os"

"github.com/anacrolix/missinggo"
"github.com/anacrolix/torrent"
Expand All @@ -27,7 +26,7 @@ func (me fileHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse
if req.Dir {
panic("read on directory")
}
pos, err := me.r.Seek(me.fn.TorrentOffset+req.Offset, os.SEEK_SET)
pos, err := me.r.Seek(me.fn.TorrentOffset+req.Offset, io.SeekStart)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions fs/filenode.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package torrentfs

import (
"os"
"io"

"bazil.org/fuse"
fusefs "bazil.org/fuse/fs"
Expand All @@ -26,6 +26,6 @@ func (fn fileNode) Attr(ctx context.Context, attr *fuse.Attr) error {

func (fn fileNode) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fusefs.Handle, error) {
r := fn.t.NewReader()
r.Seek(fn.TorrentOffset, os.SEEK_SET)
r.Seek(fn.TorrentOffset, io.SeekStart)
return fileHandle{fn, r}, nil
}
4 changes: 0 additions & 4 deletions fs/torrentfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ type node struct {
t *torrent.Torrent
}

func (n *node) fsPath() string {
return "/" + n.metadata.Name + "/" + n.path
}

type dirNode struct {
node
}
Expand Down
2 changes: 1 addition & 1 deletion fs/torrentfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func TestDownloadOnDemand(t *testing.T) {
resp := &fuse.ReadResponse{
Data: make([]byte, size),
}
h, err := node.(fusefs.NodeOpener).Open(nil, nil, nil)
h, err := node.(fusefs.NodeOpener).Open(context.TODO(), nil, nil)
require.NoError(t, err)
h.(fusefs.HandleReader).Read(netContext.Background(), &fuse.ReadRequest{
Size: int(size),
Expand Down
23 changes: 0 additions & 23 deletions iplist/iplist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ package iplist
import (
"bufio"
"bytes"
"fmt"
"net"
"strings"
"testing"

"github.com/anacrolix/missinggo"
"github.com/bradfitz/iter"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -74,27 +72,6 @@ func BenchmarkParseP2pBlocklist(b *testing.B) {
}
}

func connRemoteAddrIP(network, laddr string, dialHost string) net.IP {
l, err := net.Listen(network, laddr)
if err != nil {
panic(err)
}
go func() {
c, err := net.Dial(network, net.JoinHostPort(dialHost, fmt.Sprintf("%d", missinggo.AddrPort(l.Addr()))))
if err != nil {
panic(err)
}
defer c.Close()
}()
c, err := l.Accept()
if err != nil {
panic(err)
}
defer c.Close()
ret := missinggo.AddrIP(c.RemoteAddr())
return ret
}

func lookupOk(r Range, ok bool) bool {
return ok
}
Expand Down
1 change: 0 additions & 1 deletion mse/mse.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ func (h *handshake) finishWriting() {
h.writerCond.Wait()
}
h.writerMu.Unlock()
return
}

func (h *handshake) writer() {
Expand Down
2 changes: 2 additions & 0 deletions storage/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ func TestShortFile(t *testing.T) {
ts, err := s.OpenTorrent(info, metainfo.Hash{})
assert.NoError(t, err)
f, err := os.Create(filepath.Join(td, "a"))
require.NoError(t, err)
err = f.Truncate(1)
require.NoError(t, err)
f.Close()
var buf bytes.Buffer
p := info.Piece(0)
Expand Down

0 comments on commit cecc70f

Please sign in to comment.