mirror of
https://github.com/kopia/kopia.git
synced 2026-01-25 06:48:48 -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
40 lines
692 B
Go
40 lines
692 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/kopia/kopia/repo"
|
|
)
|
|
|
|
var (
|
|
cacheClearCommand = cacheCommands.Command("clear", "Clears the cache")
|
|
)
|
|
|
|
func runCacheClearCommand(ctx context.Context, rep *repo.DirectRepository) error {
|
|
if d := rep.Content.CachingOptions.CacheDirectory; d != "" {
|
|
printStderr("Clearing cache directory: %v.\n", d)
|
|
|
|
err := os.RemoveAll(d)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := os.MkdirAll(d, 0700); err != nil {
|
|
return err
|
|
}
|
|
|
|
printStderr("Cache cleared.\n")
|
|
|
|
return nil
|
|
}
|
|
|
|
return errors.New("caching not enabled")
|
|
}
|
|
|
|
func init() {
|
|
cacheClearCommand.Action(directRepositoryAction(runCacheClearCommand))
|
|
}
|