From 628ae799cace9a922bfba36bd6a755e515b81ee4 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Thu, 26 May 2022 13:30:52 +0200 Subject: [PATCH] repository: make flushPacks private --- internal/repository/repository.go | 6 +++--- internal/repository/repository_test.go | 15 +++------------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/internal/repository/repository.go b/internal/repository/repository.go index 1bc4d3245..77cf01989 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -519,7 +519,7 @@ func (r *Repository) SaveUnpacked(ctx context.Context, t restic.FileType, p []by // Flush saves all remaining packs and the index func (r *Repository) Flush(ctx context.Context) error { - if err := r.FlushPacks(ctx); err != nil { + if err := r.flushPacks(ctx); err != nil { return err } @@ -530,8 +530,8 @@ func (r *Repository) Flush(ctx context.Context) error { return r.idx.SaveIndex(ctx, r) } -// FlushPacks saves all remaining packs. -func (r *Repository) FlushPacks(ctx context.Context) error { +// flushPacks saves all remaining packs. +func (r *Repository) flushPacks(ctx context.Context) error { pms := []struct { t restic.BlobType pm *packerManager diff --git a/internal/repository/repository_test.go b/internal/repository/repository_test.go index 81604dea3..d32b16410 100644 --- a/internal/repository/repository_test.go +++ b/internal/repository/repository_test.go @@ -414,22 +414,13 @@ func testRepositoryIncrementalIndex(t *testing.T, version uint) { repository.IndexFull = func(*repository.Index, bool) bool { return true } - // add 15 packs + // add a few rounds of packs for j := 0; j < 5; j++ { - // add 3 packs, write intermediate index - for i := 0; i < 3; i++ { - saveRandomDataBlobs(t, repo, 5, 1<<15) - rtest.OK(t, repo.FlushPacks(context.Background())) - } + // add some packs, write intermediate index + saveRandomDataBlobs(t, repo, 20, 1<<15) rtest.OK(t, repo.Flush(context.TODO())) } - // add another 5 packs - for i := 0; i < 5; i++ { - saveRandomDataBlobs(t, repo, 5, 1<<15) - rtest.OK(t, repo.FlushPacks(context.Background())) - } - // save final index rtest.OK(t, repo.Flush(context.TODO()))