More megacheck
This commit is contained in:
parent
9757f04cf8
commit
cecc70f4cc
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -238,7 +238,6 @@ func (h *handshake) finishWriting() {
|
|||
h.writerCond.Wait()
|
||||
}
|
||||
h.writerMu.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func (h *handshake) writer() {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue