Fix #1120: Do not let the size metric underflow uint.

This commit is contained in:
Hector Sanjuan 2020-05-12 21:17:25 +02:00
parent 067619b703
commit 1880daf59d

View File

@ -98,7 +98,13 @@ func (disk *Informer) GetMetric(ctx context.Context) *api.Metric {
} else {
switch disk.config.MetricType {
case MetricFreeSpace:
metric = repoStat.StorageMax - repoStat.RepoSize
size := repoStat.RepoSize
total := repoStat.StorageMax
if size < total {
metric = total - size
} else { // Make sure we don't underflow
metric = 0
}
case MetricRepoSize:
metric = repoStat.RepoSize
}