- stats: fix incorrect loading of counters from file

This commit is contained in:
Simon Zolin 2019-09-10 18:04:43 +03:00
parent 04e2566e9e
commit ce614ab8bf

View File

@ -291,9 +291,15 @@ func serialize(u *unit) *unitDB {
func deserialize(u *unit, udb *unitDB) {
u.nTotal = udb.NTotal
for _, it := range udb.NResult {
u.nResult = append(u.nResult, int(it))
n := len(udb.NResult)
if n < len(u.nResult) {
n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult))
}
for i := 1; i <= n; i++ {
u.nResult[i] = udb.NResult[i]
}
u.domains = convertArrayToMap(udb.Domains)
u.blockedDomains = convertArrayToMap(udb.BlockedDomains)
u.clients = convertArrayToMap(udb.Clients)