mirror of
https://github.com/kopia/kopia.git
synced 2026-01-24 22:38:00 -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>
52 lines
2.1 KiB
Go
52 lines
2.1 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/kopia/kopia/repo"
|
|
"github.com/kopia/kopia/repo/blob"
|
|
"github.com/kopia/kopia/repo/content"
|
|
"github.com/kopia/kopia/repo/maintenance"
|
|
)
|
|
|
|
var (
|
|
contentRewriteCommand = contentCommands.Command("rewrite", "Rewrite content using most recent format")
|
|
contentRewriteIDs = contentRewriteCommand.Arg("contentID", "Identifiers of contents to rewrite").Strings()
|
|
contentRewriteParallelism = contentRewriteCommand.Flag("parallelism", "Number of parallel workers").Default("16").Int()
|
|
|
|
contentRewriteShortPacks = contentRewriteCommand.Flag("short", "Rewrite contents from short packs").Bool()
|
|
contentRewriteFormatVersion = contentRewriteCommand.Flag("format-version", "Rewrite contents using the provided format version").Default("-1").Int()
|
|
contentRewritePackPrefix = contentRewriteCommand.Flag("pack-prefix", "Only rewrite contents from pack blobs with a given prefix").String()
|
|
contentRewriteDryRun = contentRewriteCommand.Flag("dry-run", "Do not actually rewrite, only print what would happen").Short('n').Bool()
|
|
contentRewriteMinAge = contentRewriteCommand.Flag("min-age", "Only rewrite contents above given age").Default("1h").Duration()
|
|
)
|
|
|
|
func runContentRewriteCommand(ctx context.Context, rep repo.DirectRepositoryWriter) error {
|
|
advancedCommand(ctx)
|
|
|
|
return maintenance.RewriteContents(ctx, rep, &maintenance.RewriteContentsOptions{
|
|
ContentIDRange: contentIDRange(),
|
|
ContentIDs: toContentIDs(*contentRewriteIDs),
|
|
FormatVersion: *contentRewriteFormatVersion,
|
|
MinAge: *contentRewriteMinAge,
|
|
PackPrefix: blob.ID(*contentRewritePackPrefix),
|
|
Parallel: *contentRewriteParallelism,
|
|
ShortPacks: *contentRewriteShortPacks,
|
|
DryRun: *contentRewriteDryRun,
|
|
})
|
|
}
|
|
|
|
func toContentIDs(s []string) []content.ID {
|
|
var result []content.ID
|
|
for _, cid := range s {
|
|
result = append(result, content.ID(cid))
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
func init() {
|
|
contentRewriteCommand.Action(directRepositoryWriteAction(runContentRewriteCommand))
|
|
setupContentIDRangeFlags(contentRewriteCommand)
|
|
}
|