diff --git a/blocks.go b/blocks.go index 7f2c9081..b0f84cd9 100644 --- a/blocks.go +++ b/blocks.go @@ -17,7 +17,7 @@ func Blocks(r io.Reader, blocksize int) ([]Block, error) { var blocks []Block var offset int64 for { - lr := &io.LimitedReader{r, int64(blocksize)} + lr := &io.LimitedReader{R: r, N: int64(blocksize)} hf := sha256.New() n, err := io.Copy(hf, lr) if err != nil { diff --git a/discover/discover.go b/discover/discover.go index bdc8fd84..e4902c85 100644 --- a/discover/discover.go +++ b/discover/discover.go @@ -134,7 +134,7 @@ func (d *Discoverer) sendExtAnnouncements() { } time.Sleep(d.ExtBroadcastIntv) } - log.Println("discover/write: %v: stopping due to too many errors:", remote, err) + log.Printf("discover/write: %v: stopping due to too many errors: %v", remote, err) } func (d *Discoverer) recvAnnouncements() { diff --git a/filequeue_test.go b/filequeue_test.go index 289c69a9..bf0add74 100644 --- a/filequeue_test.go +++ b/filequeue_test.go @@ -272,7 +272,7 @@ func TestFileQueueThreadHandling(t *testing.T) { close(start) wg.Wait() if int(gotTot) != total { - t.Error("Total mismatch; %d != %d", gotTot, total) + t.Errorf("Total mismatch; %d != %d", gotTot, total) } } @@ -283,13 +283,13 @@ func TestDeleteAt(t *testing.T) { q.files = queuedFileList{{name: "a"}, {name: "b"}, {name: "c"}, {name: "d"}} q.deleteAt(i) if l := len(q.files); l != 3 { - t.Fatal("deleteAt(%d) failed; %d != 3", i, l) + t.Fatalf("deleteAt(%d) failed; %d != 3", i, l) } } q.files = queuedFileList{{name: "a"}} q.deleteAt(0) if l := len(q.files); l != 0 { - t.Fatal("deleteAt(only) failed; %d != 0", l) + t.Fatalf("deleteAt(only) failed; %d != 0", l) } } diff --git a/main.go b/main.go index 96c6c8f1..320374ab 100644 --- a/main.go +++ b/main.go @@ -502,7 +502,10 @@ func saveIndex(m *Model) { gzw := gzip.NewWriter(idxf) - protocol.IndexMessage{"local", m.ProtocolIndex()}.EncodeXDR(gzw) + protocol.IndexMessage{ + Repository: "local", + Files: m.ProtocolIndex(), + }.EncodeXDR(gzw) gzw.Close() idxf.Close() os.Rename(fullName+".tmp", fullName) diff --git a/protocol/protocol.go b/protocol/protocol.go index 9fca8f88..2e9920e7 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -268,7 +268,7 @@ loop: break loop } if hdr.version != 0 { - c.close(fmt.Errorf("Protocol error: %s: unknown message version %#x", c.ID, hdr.version)) + c.close(fmt.Errorf("Protocol error: %s: unknown message version %#x", c.id, hdr.version)) break loop } @@ -371,7 +371,7 @@ loop: } default: - c.close(fmt.Errorf("Protocol error: %s: unknown message type %#x", c.ID, hdr.msgType)) + c.close(fmt.Errorf("Protocol error: %s: unknown message type %#x", c.id, hdr.msgType)) break loop } } diff --git a/protocol/protocol_test.go b/protocol/protocol_test.go index f15a6773..c7abb439 100644 --- a/protocol/protocol_test.go +++ b/protocol/protocol_test.go @@ -99,16 +99,16 @@ func TestRequestResponseErr(t *testing.T) { t.Errorf("Incorrect response data %q", string(d)) } if m0.repo != "default" { - t.Error("Incorrect repo %q", m0.repo) + t.Errorf("Incorrect repo %q", m0.repo) } if m0.name != "tn" { - t.Error("Incorrect name %q", m0.name) + t.Errorf("Incorrect name %q", m0.name) } if m0.offset != 1234 { - t.Error("Incorrect offset %d", m0.offset) + t.Errorf("Incorrect offset %d", m0.offset) } if m0.size != 5678 { - t.Error("Incorrect size %d", m0.size) + t.Errorf("Incorrect size %d", m0.size) } t.Logf("Pass at %d+%d bytes", i, j) pass = true diff --git a/suppressor_test.go b/suppressor_test.go index 26cc5e3b..87eec216 100644 --- a/suppressor_test.go +++ b/suppressor_test.go @@ -21,7 +21,7 @@ func TestSuppressor(t *testing.T) { // bw is 10000 / 10 = 1000 t1 = t0.Add(10 * time.Second) if bw := s.changes["foo"].bandwidth(t1); bw != 1000 { - t.Error("Incorrect bw %d", bw) + t.Errorf("Incorrect bw %d", bw) } sup, prev = s.suppress("foo", 10000, t1) if sup { @@ -34,7 +34,7 @@ func TestSuppressor(t *testing.T) { // bw is (10000 + 10000) / 11 = 1818 t1 = t0.Add(11 * time.Second) if bw := s.changes["foo"].bandwidth(t1); bw != 1818 { - t.Error("Incorrect bw %d", bw) + t.Errorf("Incorrect bw %d", bw) } sup, prev = s.suppress("foo", 100500, t1) if sup { @@ -47,7 +47,7 @@ func TestSuppressor(t *testing.T) { // bw is (10000 + 10000 + 100500) / 12 = 10041 t1 = t0.Add(12 * time.Second) if bw := s.changes["foo"].bandwidth(t1); bw != 10041 { - t.Error("Incorrect bw %d", bw) + t.Errorf("Incorrect bw %d", bw) } sup, prev = s.suppress("foo", 10000000, t1) // value will be ignored if !sup { @@ -60,7 +60,7 @@ func TestSuppressor(t *testing.T) { // bw is (10000 + 10000 + 100500) / 15 = 8033 t1 = t0.Add(15 * time.Second) if bw := s.changes["foo"].bandwidth(t1); bw != 8033 { - t.Error("Incorrect bw %d", bw) + t.Errorf("Incorrect bw %d", bw) } sup, prev = s.suppress("foo", 10000000, t1) if sup {