cachestats: Fix nil pointer if not a cache remote - fixes #1855

Also don't retry or show stats
This commit is contained in:
Nick Craig-Wood 2017-11-24 10:21:23 +00:00
parent 6448c445f5
commit 1248beb0b2

View File

@ -38,11 +38,14 @@ Print cache stats for a remote in JSON format
}
fsrc := cmd.NewFsSrc(args)
cmd.Run(true, true, command, func() error {
cmd.Run(false, false, command, func() error {
var fsCache *cache.Fs
fsCache, ok := fsrc.(*cache.Fs)
if !ok {
fsCache, ok = fsrc.Features().UnWrap().(*cache.Fs)
unwrap := fsrc.Features().UnWrap
if unwrap != nil {
fsCache, ok = unwrap().(*cache.Fs)
}
if !ok {
return errors.Errorf("%s: is not a cache remote", fsrc.Name())
}