mirror of
https://github.com/restic/restic.git
synced 2025-01-03 05:35:43 +00:00
mem: check upload length before storing upload
This commit is contained in:
parent
0e5f2fff71
commit
f740b2fb23
1 changed files with 3 additions and 3 deletions
|
@ -81,14 +81,14 @@ func (be *MemoryBackend) Save(ctx context.Context, h restic.Handle, rd restic.Re
|
|||
return err
|
||||
}
|
||||
|
||||
be.data[h] = buf
|
||||
debug.Log("saved %v bytes at %v", len(buf), h)
|
||||
|
||||
// sanity check
|
||||
if int64(len(buf)) != rd.Length() {
|
||||
return errors.Errorf("wrote %d bytes instead of the expected %d bytes", len(buf), rd.Length())
|
||||
}
|
||||
|
||||
be.data[h] = buf
|
||||
debug.Log("saved %v bytes at %v", len(buf), h)
|
||||
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue