Embed context into ReaderAt

The io.Reader interface does not support contexts, such that it is
necessary to embed the context into the backendReaderAt struct. This has
the problem that a reader might suddenly stop working when it's
contained context is canceled. However, this is now problem here as the
reader instances never escape the calling function.
This commit is contained in:
Michael Eischer committed 2020-10-09 22:39:07 +02:00
1 parent d6cfe857b7
commit e638b46a13
4 files changed
+13 -10

No files matched your search

+2 -2
View File
@@ -128,7 +128,7 @@ func TestUnpackReadSeeker(t *testing.T) {
handle := restic.Handle{Type: restic.PackFile, Name: id.String()}
rtest.OK(t, b.Save(context.TODO(), handle, restic.NewByteReader(packData)))
verifyBlobs(t, bufs, k, restic.ReaderAt(b, handle), packSize)
verifyBlobs(t, bufs, k, restic.ReaderAt(context.TODO(), b, handle), packSize)
}
func TestShortPack(t *testing.T) {
@@ -141,5 +141,5 @@ func TestShortPack(t *testing.T) {
handle := restic.Handle{Type: restic.PackFile, Name: id.String()}
rtest.OK(t, b.Save(context.TODO(), handle, restic.NewByteReader(packData)))
verifyBlobs(t, bufs, k, restic.ReaderAt(b, handle), packSize)
verifyBlobs(t, bufs, k, restic.ReaderAt(context.TODO(), b, handle), packSize)
}