From ce614ab8bf8886f177359007459b4b840ab51b83 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Tue, 10 Sep 2019 18:04:43 +0300 Subject: [PATCH] - stats: fix incorrect loading of counters from file --- stats/stats_unit.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/stats/stats_unit.go b/stats/stats_unit.go index e4eba676..5ac574a0 100644 --- a/stats/stats_unit.go +++ b/stats/stats_unit.go @@ -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)