fix radix set account

This commit is contained in:
Radu Ioan Fericean
2015-11-16 15:17:48 +02:00
parent ebe9dc4f35
commit 576e16259d

View File

@@ -620,6 +620,18 @@ func (rs *RedisStorage) GetAccount(key string) (ub *Account, err error) {
}
func (rs *RedisStorage) SetAccount(ub *Account) (err error) {
// never override existing account with an empty one
// UPDATE: if all balances expired and were cleaned it makes
// sense to write empty balance map
if len(ub.BalanceMap) == 0 {
if ac, err := rs.GetAccount(ub.Id); err == nil && !ac.allBalancesExpired() {
ac.ActionTriggers = ub.ActionTriggers
ac.UnitCounters = ub.UnitCounters
ac.AllowNegative = ub.AllowNegative
ac.Disabled = ub.Disabled
ub = ac
}
}
result, err := rs.ms.Marshal(ub)
err = rs.db.Cmd("SET", utils.ACCOUNT_PREFIX+ub.Id, result).Err
return