From 88b754649d26da201c454246b6eaf4c89e19babc Mon Sep 17 00:00:00 2001 From: Rached Ben Mustapha Date: Sun, 7 Feb 2016 21:20:22 +0000 Subject: [PATCH] Use a new buffer for each pack in rebuild-index The same buffer was being used for downloading multiple packs and when a bigger-sized buffer was reused to download a new pack, the call to `io.ReadFull` from some backends would fail with an `unexpected EOF` error because the number of bytes read would be smaller than the buffer size. --- cmd/restic/cmd_rebuild_index.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/restic/cmd_rebuild_index.go b/cmd/restic/cmd_rebuild_index.go index 27dae2392..45b9da6c0 100644 --- a/cmd/restic/cmd_rebuild_index.go +++ b/cmd/restic/cmd_rebuild_index.go @@ -125,7 +125,6 @@ func (cmd CmdRebuildIndex) RebuildIndex() error { cmd.global.Printf("checking for additional packs\n") newPacks := 0 - var buf []byte for packID := range cmd.repo.List(backend.Data, done) { if packsDone.Has(packID) { continue @@ -137,6 +136,7 @@ func (cmd CmdRebuildIndex) RebuildIndex() error { var err error h := backend.Handle{Type: backend.Data, Name: packID.String()} + buf := make([]byte, 0) buf, err = backend.LoadAll(cmd.repo.Backend(), h, buf) if err != nil { debug.Log("RebuildIndex.RebuildIndex", "error while loading pack %v", packID.Str())