repository: remove clearIndex and packSize from public interface
This commit is contained in:
parent
4df887406f
commit
8f1e70cd9b
4 changed files with 11 additions and 13 deletions
|
@ -313,7 +313,7 @@ func packInfoFromIndex(ctx context.Context, idx restic.ListBlobser, usedBlobs re
|
||||||
return usedBlobs, indexPack, nil
|
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()
|
removePacksFirst := restic.NewIDSet()
|
||||||
removePacks := restic.NewIDSet()
|
removePacks := restic.NewIDSet()
|
||||||
repackPacks := restic.NewIDSet()
|
repackPacks := restic.NewIDSet()
|
||||||
|
@ -322,10 +322,10 @@ func decidePackAction(ctx context.Context, opts PruneOptions, repo restic.Reposi
|
||||||
var repackSmallCandidates []packInfoWithID
|
var repackSmallCandidates []packInfoWithID
|
||||||
repoVersion := repo.Config().Version
|
repoVersion := repo.Config().Version
|
||||||
// only repack very small files by default
|
// only repack very small files by default
|
||||||
targetPackSize := repo.PackSize() / 25
|
targetPackSize := repo.packSize() / 25
|
||||||
if opts.RepackSmall {
|
if opts.RepackSmall {
|
||||||
// consider files with at least 80% of the target size as large enough
|
// 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
|
// 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
|
// drop outdated in-memory index
|
||||||
repo.ClearIndex()
|
repo.clearIndex()
|
||||||
|
|
||||||
printer.P("done\n")
|
printer.P("done\n")
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -107,7 +107,7 @@ func RepairIndex(ctx context.Context, repo *Repository, opts RepairIndexOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop outdated in-memory index
|
// drop outdated in-memory index
|
||||||
repo.ClearIndex()
|
repo.clearIndex()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,8 +146,8 @@ func (r *Repository) Config() restic.Config {
|
||||||
return r.cfg
|
return r.cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackSize return the target size of a pack file when uploading
|
// packSize return the target size of a pack file when uploading
|
||||||
func (r *Repository) PackSize() uint {
|
func (r *Repository) packSize() uint {
|
||||||
return r.opts.PackSize
|
return r.opts.PackSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,8 +541,8 @@ func (r *Repository) StartPackUploader(ctx context.Context, wg *errgroup.Group)
|
||||||
innerWg, ctx := errgroup.WithContext(ctx)
|
innerWg, ctx := errgroup.WithContext(ctx)
|
||||||
r.packerWg = innerWg
|
r.packerWg = innerWg
|
||||||
r.uploader = newPackerUploader(ctx, innerWg, r, r.be.Connections())
|
r.uploader = newPackerUploader(ctx, innerWg, r, r.be.Connections())
|
||||||
r.treePM = newPackerManager(r.key, restic.TreeBlob, 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)
|
r.dataPM = newPackerManager(r.key, restic.DataBlob, r.packSize(), r.uploader.QueuePacker)
|
||||||
|
|
||||||
wg.Go(func() error {
|
wg.Go(func() error {
|
||||||
return innerWg.Wait()
|
return innerWg.Wait()
|
||||||
|
@ -612,7 +612,7 @@ func (r *Repository) SetIndex(i restic.MasterIndex) error {
|
||||||
return r.prepareCache()
|
return r.prepareCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repository) ClearIndex() {
|
func (r *Repository) clearIndex() {
|
||||||
r.idx = index.NewMasterIndex()
|
r.idx = index.NewMasterIndex()
|
||||||
r.configureIndex()
|
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
|
// 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 {
|
err = index.ForAllIndexes(ctx, indexList, r, func(_ restic.ID, idx *index.Index, _ bool, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -19,11 +19,9 @@ type Repository interface {
|
||||||
// Connections returns the maximum number of concurrent backend operations
|
// Connections returns the maximum number of concurrent backend operations
|
||||||
Connections() uint
|
Connections() uint
|
||||||
Config() Config
|
Config() Config
|
||||||
PackSize() uint
|
|
||||||
Key() *crypto.Key
|
Key() *crypto.Key
|
||||||
|
|
||||||
LoadIndex(context.Context, *progress.Counter) error
|
LoadIndex(context.Context, *progress.Counter) error
|
||||||
ClearIndex()
|
|
||||||
SetIndex(MasterIndex) error
|
SetIndex(MasterIndex) error
|
||||||
SaveIndex(ctx context.Context, excludePacks IDSet, extraObsolete IDs, opts MasterIndexSaveOpts) error
|
SaveIndex(ctx context.Context, excludePacks IDSet, extraObsolete IDs, opts MasterIndexSaveOpts) error
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue