diff --git a/internal/repository/prune.go b/internal/repository/prune.go index 66eab28b2..712986e61 100644 --- a/internal/repository/prune.go +++ b/internal/repository/prune.go @@ -313,7 +313,7 @@ func packInfoFromIndex(ctx context.Context, idx restic.ListBlobser, usedBlobs re return usedBlobs, indexPack, nil } -func decidePackAction(ctx context.Context, opts PruneOptions, repo restic.Repository, indexPack map[restic.ID]packInfo, stats *PruneStats, printer progress.Printer) (PrunePlan, error) { +func decidePackAction(ctx context.Context, opts PruneOptions, repo *Repository, indexPack map[restic.ID]packInfo, stats *PruneStats, printer progress.Printer) (PrunePlan, error) { removePacksFirst := restic.NewIDSet() removePacks := restic.NewIDSet() repackPacks := restic.NewIDSet() @@ -322,10 +322,10 @@ func decidePackAction(ctx context.Context, opts PruneOptions, repo restic.Reposi var repackSmallCandidates []packInfoWithID repoVersion := repo.Config().Version // only repack very small files by default - targetPackSize := repo.PackSize() / 25 + targetPackSize := repo.packSize() / 25 if opts.RepackSmall { // consider files with at least 80% of the target size as large enough - targetPackSize = repo.PackSize() / 5 * 4 + targetPackSize = repo.packSize() / 5 * 4 } // loop over all packs and decide what to do @@ -612,7 +612,7 @@ func (plan *PrunePlan) Execute(ctx context.Context, printer progress.Printer) (e } // drop outdated in-memory index - repo.ClearIndex() + repo.clearIndex() printer.P("done\n") return nil diff --git a/internal/repository/repair_index.go b/internal/repository/repair_index.go index a7d94fcf8..c20641d50 100644 --- a/internal/repository/repair_index.go +++ b/internal/repository/repair_index.go @@ -107,7 +107,7 @@ func RepairIndex(ctx context.Context, repo *Repository, opts RepairIndexOptions, } // drop outdated in-memory index - repo.ClearIndex() + repo.clearIndex() return nil } diff --git a/internal/repository/repository.go b/internal/repository/repository.go index 4aa8106ab..48bb9a0ad 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -146,8 +146,8 @@ func (r *Repository) Config() restic.Config { return r.cfg } -// PackSize return the target size of a pack file when uploading -func (r *Repository) PackSize() uint { +// packSize return the target size of a pack file when uploading +func (r *Repository) packSize() uint { return r.opts.PackSize } @@ -541,8 +541,8 @@ func (r *Repository) StartPackUploader(ctx context.Context, wg *errgroup.Group) innerWg, ctx := errgroup.WithContext(ctx) r.packerWg = innerWg r.uploader = newPackerUploader(ctx, innerWg, r, r.be.Connections()) - r.treePM = newPackerManager(r.key, restic.TreeBlob, r.PackSize(), r.uploader.QueuePacker) - r.dataPM = newPackerManager(r.key, restic.DataBlob, r.PackSize(), r.uploader.QueuePacker) + r.treePM = newPackerManager(r.key, restic.TreeBlob, r.packSize(), r.uploader.QueuePacker) + r.dataPM = newPackerManager(r.key, restic.DataBlob, r.packSize(), r.uploader.QueuePacker) wg.Go(func() error { return innerWg.Wait() @@ -612,7 +612,7 @@ func (r *Repository) SetIndex(i restic.MasterIndex) error { return r.prepareCache() } -func (r *Repository) ClearIndex() { +func (r *Repository) clearIndex() { r.idx = index.NewMasterIndex() r.configureIndex() } @@ -646,7 +646,7 @@ func (r *Repository) LoadIndex(ctx context.Context, p *progress.Counter) error { } // reset in-memory index before loading it from the repository - r.ClearIndex() + r.clearIndex() err = index.ForAllIndexes(ctx, indexList, r, func(_ restic.ID, idx *index.Index, _ bool, err error) error { if err != nil { diff --git a/internal/restic/repository.go b/internal/restic/repository.go index ee32beb7e..06344a630 100644 --- a/internal/restic/repository.go +++ b/internal/restic/repository.go @@ -19,11 +19,9 @@ type Repository interface { // Connections returns the maximum number of concurrent backend operations Connections() uint Config() Config - PackSize() uint Key() *crypto.Key LoadIndex(context.Context, *progress.Counter) error - ClearIndex() SetIndex(MasterIndex) error SaveIndex(ctx context.Context, excludePacks IDSet, extraObsolete IDs, opts MasterIndexSaveOpts) error