More megacheck

This commit is contained in:
Matt Joiner 2017-11-08 00:12:34 +11:00
parent 9757f04cf8
commit cecc70f4cc
7 changed files with 6 additions and 33 deletions

View File

@ -3,7 +3,6 @@ package torrentfs
import (
"context"
"io"
"os"
"github.com/anacrolix/missinggo"
"github.com/anacrolix/torrent"
@ -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)
}

View File

@ -1,7 +1,7 @@
package torrentfs
import (
"os"
"io"
"bazil.org/fuse"
fusefs "bazil.org/fuse/fs"
@ -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
}

View File

@ -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
}

View File

@ -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),

View File

@ -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"
@ -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
}

View File

@ -238,7 +238,6 @@ func (h *handshake) finishWriting() {
h.writerCond.Wait()
}
h.writerMu.Unlock()
return
}
func (h *handshake) writer() {

View File

@ -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)