diff --git a/internal/archiver/archiver_test.go b/internal/archiver/archiver_test.go index 60859857e..32bb336a6 100644 --- a/internal/archiver/archiver_test.go +++ b/internal/archiver/archiver_test.go @@ -1969,7 +1969,7 @@ type failSaveRepo struct { func (f *failSaveRepo) SaveBlob(ctx context.Context, t restic.BlobType, buf []byte, id restic.ID, storeDuplicate bool) (restic.ID, bool, int, error) { val := atomic.AddInt32(&f.cnt, 1) if val >= f.failAfter { - return restic.ID{}, false, 0, f.err + return restic.Hash(buf), false, 0, f.err } return f.Repository.SaveBlob(ctx, t, buf, id, storeDuplicate) diff --git a/internal/archiver/file_saver.go b/internal/archiver/file_saver.go index c7303b929..346bf736e 100644 --- a/internal/archiver/file_saver.go +++ b/internal/archiver/file_saver.go @@ -128,6 +128,11 @@ func (s *FileSaver) saveFile(ctx context.Context, chnker *chunker.Chunker, snPat if isCompleted { panic("completed twice") } + for _, id := range fnr.node.Content { + if id.IsNull() { + panic("completed file with null ID") + } + } isCompleted = true finish(fnr) } diff --git a/internal/archiver/file_saver_test.go b/internal/archiver/file_saver_test.go index e32250496..840721527 100644 --- a/internal/archiver/file_saver_test.go +++ b/internal/archiver/file_saver_test.go @@ -35,7 +35,12 @@ func startFileSaver(ctx context.Context, t testing.TB) (*FileSaver, context.Cont wg, ctx := errgroup.WithContext(ctx) saveBlob := func(ctx context.Context, tpe restic.BlobType, buf *Buffer, cb func(SaveBlobResponse)) { - cb(SaveBlobResponse{}) + cb(SaveBlobResponse{ + id: restic.Hash(buf.Data), + length: len(buf.Data), + sizeInRepo: len(buf.Data), + known: false, + }) } workers := uint(runtime.NumCPU())