mirror of
https://github.com/kopia/kopia.git
synced 2026-01-03 20:17:53 -05:00
- `repo.Repository` is now read-only and only has methods that can be supported over kopia server
- `repo.RepositoryWriter` has read-write methods that can be supported over kopia server
- `repo.DirectRepository` is read-only and contains all methods of `repo.Repository` plus some low-level methods for data inspection
- `repo.DirectRepositoryWriter` contains write methods for `repo.DirectRepository`
- `repo.Reader` removed and merged with `repo.Repository`
- `repo.Writer` became `repo.RepositoryWriter`
- `*repo.DirectRepository` struct became `repo.DirectRepository`
interface
Getting `{Direct}RepositoryWriter` requires using `NewWriter()` or `NewDirectWriter()` on a read-only repository and multiple simultaneous writers are supported at the same time, each writing to their own indexes and pack blobs.
`repo.Open` returns `repo.Repository` (which is also `repo.RepositoryWriter`).
* content: removed implicit flush on content manager close
* repo: added tests for WriteSession() and implicit flush behavior
* invalidate manifest manager after write session
* cli: disable maintenance in 'kopia server start'
Server will close the repository before completing.
* repo: unconditionally close RepositoryWriter in {Direct,}WriteSession
* repo: added panic in case somebody tries to create RepositoryWriter after closing repository
- used atomic to manage SharedManager.closed
* removed stale example
* linter: fixed spurious failures
Co-authored-by: Julio López <julio+gh@kasten.io>
38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/kopia/kopia/internal/clock"
|
|
"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()
|
|
optimizeDropDeletedOlderThan = optimizeCommand.Flag("drop-deleted-older-than", "Drop deleted contents above given age").Duration()
|
|
optimizeDropContents = optimizeCommand.Flag("drop-contents", "Drop contents with given IDs").Strings()
|
|
optimizeAllIndexes = optimizeCommand.Flag("all", "Optimize all indexes, even those above maximum size.").Bool()
|
|
)
|
|
|
|
func runOptimizeCommand(ctx context.Context, rep repo.DirectRepositoryWriter) error {
|
|
advancedCommand(ctx)
|
|
|
|
opt := content.CompactOptions{
|
|
MaxSmallBlobs: *optimizeMaxSmallBlobs,
|
|
AllIndexes: *optimizeAllIndexes,
|
|
DropContents: toContentIDs(*optimizeDropContents),
|
|
}
|
|
|
|
if age := *optimizeDropDeletedOlderThan; age > 0 {
|
|
opt.DropDeletedBefore = clock.Now().Add(-age)
|
|
}
|
|
|
|
return rep.ContentManager().CompactIndexes(ctx, opt)
|
|
}
|
|
|
|
func init() {
|
|
optimizeCommand.Action(directRepositoryWriteAction(runOptimizeCommand))
|
|
}
|