mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-19 22:28:45 +05:00
fixes for radix branch
This commit is contained in:
@@ -468,6 +468,18 @@ func (ms *MapStorage) GetAccount(key string) (ub *Account, err error) {
|
||||
}
|
||||
|
||||
func (ms *MapStorage) 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 := ms.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 := ms.ms.Marshal(ub)
|
||||
ms.dict[utils.ACCOUNT_PREFIX+ub.Id] = result
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user