mirror of
https://github.com/kopia/kopia.git
synced 2026-01-02 19:47:51 -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>
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/kopia/kopia/internal/units"
|
|
"github.com/kopia/kopia/repo"
|
|
)
|
|
|
|
var (
|
|
cacheSetParamsCommand = cacheCommands.Command("set", "Sets parameters local caching of repository data")
|
|
|
|
cacheSetDirectory = cacheSetParamsCommand.Flag("cache-directory", "Directory where to store cache files").String()
|
|
cacheSetContentCacheSizeMB = cacheSetParamsCommand.Flag("content-cache-size-mb", "Size of local content cache").PlaceHolder("MB").Default("-1").Int64()
|
|
cacheSetMaxMetadataCacheSizeMB = cacheSetParamsCommand.Flag("metadata-cache-size-mb", "Size of local metadata cache").PlaceHolder("MB").Default("-1").Int64()
|
|
cacheSetMaxListCacheDuration = cacheSetParamsCommand.Flag("max-list-cache-duration", "Duration of index cache").Default("-1ns").Duration()
|
|
)
|
|
|
|
func runCacheSetCommand(ctx context.Context, rep repo.DirectRepositoryWriter) error {
|
|
opts := rep.CachingOptions().CloneOrDefault()
|
|
|
|
changed := 0
|
|
|
|
if v := *cacheSetDirectory; v != "" {
|
|
log(ctx).Infof("setting cache directory to %v", v)
|
|
opts.CacheDirectory = v
|
|
changed++
|
|
}
|
|
|
|
if v := *cacheSetContentCacheSizeMB; v != -1 {
|
|
v *= 1e6 // convert MB to bytes
|
|
log(ctx).Infof("changing content cache size to %v", units.BytesStringBase10(v))
|
|
opts.MaxCacheSizeBytes = v
|
|
changed++
|
|
}
|
|
|
|
if v := *cacheSetMaxMetadataCacheSizeMB; v != -1 {
|
|
v *= 1e6 // convert MB to bytes
|
|
log(ctx).Infof("changing metadata cache size to %v", units.BytesStringBase10(v))
|
|
opts.MaxMetadataCacheSizeBytes = v
|
|
changed++
|
|
}
|
|
|
|
if v := *cacheSetMaxListCacheDuration; v != -1 {
|
|
log(ctx).Infof("changing list cache duration to %v", v)
|
|
opts.MaxListCacheDurationSec = int(v.Seconds())
|
|
changed++
|
|
}
|
|
|
|
if changed == 0 {
|
|
return errors.Errorf("no changes")
|
|
}
|
|
|
|
return rep.SetCachingOptions(ctx, opts)
|
|
}
|
|
|
|
func init() {
|
|
cacheSetParamsCommand.Action(directRepositoryWriteAction(runCacheSetCommand))
|
|
}
|