Files
kopia/cli/command_cache_info.go
Jarek Kowalski 54edb97b3a refactoring: renamed repo/block to repo/content
Also introduced strongly typed content.ID and manifest.ID (instead of string)

This aligns identifiers across all layers of repository:

blob.ID
content.ID
object.ID
manifest.ID
2019-06-01 22:24:19 -07:00

35 lines
815 B
Go

package cli
import (
"context"
"fmt"
"path/filepath"
"github.com/kopia/kopia/internal/units"
"github.com/kopia/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, "contents"))
if err != nil {
return err
}
fmt.Printf("Usage: %v files %v\n", fileCount, units.BytesStringBase2(totalFileSize))
return nil
}
func init() {
cacheInfoCommand.Action(repositoryAction(runCacheInfoCommand))
}