This commit is contained in:
Matt Joiner 2016-02-02 00:44:29 +11:00
parent 430f26f726
commit 0e85ff190d
3 changed files with 10 additions and 6 deletions

View File

@ -91,7 +91,7 @@ func main() {
parser.Usage = "[OPTIONS] (magnet URI or .torrent file path)..."
posArgs, err := parser.Parse()
if err != nil {
fmt.Fprintln(os.Stderr, "Download from the BitTorrent network.\n")
fmt.Fprintf(os.Stderr, "%s", "Download from the BitTorrent network.\n\n")
fmt.Println(err)
os.Exit(2)
}

View File

@ -4,10 +4,11 @@ import (
"net"
"testing"
"github.com/anacrolix/torrent/bencode"
"github.com/anacrolix/torrent/util"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/anacrolix/torrent/bencode"
"github.com/anacrolix/torrent/util"
)
func testMarshalUnmarshalMsg(t *testing.T, m Msg, expected string) {
@ -71,7 +72,10 @@ func TestMarshalUnmarshalMsg(t *testing.T) {
R: &Return{
ID: "\xeb\xff6isQ\xffJ\xec)ͺ\xab\xf2\xfb\xe3F|\xc2g",
},
IP: util.CompactPeer{net.IPv4(124, 168, 180, 8).To4(), 62844},
IP: util.CompactPeer{
IP: net.IPv4(124, 168, 180, 8).To4(),
Port: 62844,
},
}, "d2:ip6:|\xa8\xb4\b\xf5|1:rd2:id20:\xeb\xff6isQ\xffJ\xec)ͺ\xab\xf2\xfb\xe3F|\xc2ge1:t1:\x031:y1:re")
}

View File

@ -92,12 +92,12 @@ func (info *Info) writeFiles(w io.Writer, open func(fi FileInfo) (io.ReadCloser,
for _, fi := range info.UpvertedFiles() {
r, err := open(fi)
if err != nil {
return fmt.Errorf("error opening %s: %s", fi, err)
return fmt.Errorf("error opening %v: %s", fi, err)
}
wn, err := io.CopyN(w, r, fi.Length)
r.Close()
if wn != fi.Length || err != nil {
return fmt.Errorf("error hashing %s: %s", fi, err)
return fmt.Errorf("error hashing %v: %s", fi, err)
}
}
return nil