mirror of
https://github.com/kopia/kopia.git
synced 2026-01-24 14:28:06 -05:00
instead of having time-based naming, block manager will perform occasional compaction at startup time and delete unwanted blocks The protocol is safe from concurrency standpoint and provides eventual consistency. We only delete blocks after creating compacted blocks. We retry loading index until (any) consistent index is fetched (possibly from cache) and all underlying blocks are also available, not necessarily the latest ones. TODO - we need to periodically snapshot block index contents, so that if we have a bug somewhere in compaction code, we have a way of restoring working indexes.
22 lines
730 B
Go
22 lines
730 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/kopia/kopia/repo"
|
|
)
|
|
|
|
var (
|
|
optimizeCommand = blockIndexCommands.Command("optimize", "Optimize block indexes.")
|
|
optimizeMinSmallBlocks = blockIndexCommands.Flag("min-small-blocks", "Minimum number of small blocks that can be left after compaction.").Default("1").Int()
|
|
optimizeMaxSmallBlocks = blockIndexCommands.Flag("max-small-blocks", "Maximum number of small blocks that can be left after compaction.").Default("1").Int()
|
|
)
|
|
|
|
func runOptimizeCommand(ctx context.Context, rep *repo.Repository) error {
|
|
return rep.Blocks.CompactIndexes(ctx, *optimizeMinSmallBlocks, *optimizeMaxSmallBlocks)
|
|
}
|
|
|
|
func init() {
|
|
optimizeCommand.Action(repositoryAction(runOptimizeCommand))
|
|
}
|