[counter] Remove stored counter value on zero value

Rationale: The counter store is of `map[string]int64` and therefor for
an non-existent counter always `0`. As that is the default behaviour we
don't need to waste storage space by storing counters being `0`.

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2022-02-20 15:15:16 +01:00
parent d51dd27630
commit c950b2c38b
Signed by: luzifer
GPG Key ID: 0066F03ED215AD7D

View File

@ -294,7 +294,11 @@ func (s *storageFile) UpdateCounter(counter string, value int64, absolute bool)
value = s.Counters[counter] + value value = s.Counters[counter] + value
} }
s.Counters[counter] = value if value == 0 {
delete(s.Counters, counter)
} else {
s.Counters[counter] = value
}
return errors.Wrap(s.Save(), "saving store") return errors.Wrap(s.Save(), "saving store")
} }