1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2025-03-09 00:00:02 +01:00

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.
This commit is contained in:
Rached Ben Mustapha 2016-02-07 21:20:22 +00:00
parent 57a24b2cdf
commit 88b754649d

View file

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