mirror of
https://github.com/kopia/kopia.git
synced 2026-05-24 14:44:47 -04:00
refactored cache commands
This commit is contained in:
34
cli/command_cache_info.go
Normal file
34
cli/command_cache_info.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/kopia/kopia/internal/units"
|
||||
"github.com/kopia/kopia/repo"
|
||||
)
|
||||
|
||||
var (
|
||||
cacheInfoCommand = cacheCommands.Command("info", "Sets parameters local caching of repository data").Hidden()
|
||||
cacheInfoPathOnly = cacheInfoCommand.Flag("path", "Only display cache path").Bool()
|
||||
)
|
||||
|
||||
func runCacheInfoCommand(ctx context.Context, rep *repo.Repository) error {
|
||||
fmt.Println(rep.CacheDirectory)
|
||||
if *cacheInfoPathOnly {
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Debugf("scanning cache...")
|
||||
fileCount, totalFileSize, err := scanCacheDir(filepath.Join(rep.CacheDirectory, "blocks"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Usage: %v files %v\n", fileCount, units.BytesStringBase2(totalFileSize))
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
cacheInfoCommand.Action(repositoryAction(runCacheInfoCommand))
|
||||
}
|
||||
Reference in New Issue
Block a user