mirror of
https://github.com/octoleo/restic.git
synced 2024-11-23 05:12:10 +00:00
Merge pull request #3248 from MichaelEischer/backend-cleanups
Backend code and test cleanups
This commit is contained in:
commit
f647614e24
@ -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()
|
||||
}
|
||||
|
||||
|
@ -577,13 +577,15 @@ func (s *Suite) TestSaveError(t *testing.T) {
|
||||
}()
|
||||
|
||||
length := rand.Intn(1<<23) + 200000
|
||||
data := test.Random(23, length)
|
||||
data := test.Random(24, length)
|
||||
var id restic.ID
|
||||
copy(id[:], data)
|
||||
|
||||
// test that incomplete uploads fail
|
||||
h := restic.Handle{Type: restic.PackFile, Name: id.String()}
|
||||
err := b.Save(context.TODO(), h, &incompleteByteReader{ByteReader: *restic.NewByteReader(data)})
|
||||
// try to delete possible leftovers
|
||||
_ = s.delayedRemove(t, b, h)
|
||||
if err == nil {
|
||||
t.Fatal("incomplete upload did not fail")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user