mirror of
https://github.com/kopia/kopia.git
synced 2026-01-25 23:08:01 -05:00
* This is 99% mechanical: Extracted repo.Repository interface that only exposes high-level object and manifest management methods, but not blob nor content management. Renamed old *repo.Repository to *repo.DirectRepository Reviewed codebase to only depend on repo.Repository as much as possible, but added way for low-level CLI commands to use DirectRepository. * PR fixes
28 lines
1010 B
Go
28 lines
1010 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/kopia/kopia/repo"
|
|
"github.com/kopia/kopia/repo/content"
|
|
)
|
|
|
|
var (
|
|
optimizeCommand = indexCommands.Command("optimize", "Optimize indexes blobs.")
|
|
optimizeMaxSmallBlobs = optimizeCommand.Flag("max-small-blobs", "Maximum number of small index blobs that can be left after compaction.").Default("1").Int()
|
|
optimizeSkipDeletedOlderThan = optimizeCommand.Flag("skip-deleted-older-than", "Skip deleted blobs above given age").Duration()
|
|
optimizeAllIndexes = optimizeCommand.Flag("all", "Optimize all indexes, even those above maximum size.").Bool()
|
|
)
|
|
|
|
func runOptimizeCommand(ctx context.Context, rep *repo.DirectRepository) error {
|
|
return rep.Content.CompactIndexes(ctx, content.CompactOptions{
|
|
MaxSmallBlobs: *optimizeMaxSmallBlobs,
|
|
AllIndexes: *optimizeAllIndexes,
|
|
SkipDeletedOlderThan: *optimizeSkipDeletedOlderThan,
|
|
})
|
|
}
|
|
|
|
func init() {
|
|
optimizeCommand.Action(directRepositoryAction(runOptimizeCommand))
|
|
}
|