change cache status display

This commit is contained in:
ston1th 2022-03-17 00:51:48 +01:00
commit f3e2a9240d

View file

@ -279,7 +279,11 @@ func (fs *FS) CacheStatus(name string) int {
fs.mu.RLock()
defer fs.mu.RUnlock()
if md, ok := fs.md[name]; ok {
return int(math.Round(float64(md.Chunks.Size()) / float64(md.Size) * 100))
size := md.Chunks.Size()
if size == 0 {
return -1
}
return int(math.Round(float64(size) / float64(md.Size) * 100))
}
return -1
}