Files
kopia/cli/command_cache_info.go
Jarek Kowalski 2787011e02 Revamped kopia.io website.
Added build pipeline to keep the reference in sync with the code.
2019-05-09 22:11:03 -07:00

35 lines
807 B
Go

package cli
import (
"context"
"fmt"
"path/filepath"
"github.com/kopia/kopia/internal/units"
"github.com/kopia/repo"
)
var (
cacheInfoCommand = cacheCommands.Command("info", "Displays cache information and statistics")
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))
}