mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-24 06:48:35 +02:00
fix: handle None from Redis in get_message_counter
The int response callback on hget raises TypeError when the key is missing, so the None check in the mixin never actually executed. Bypass the callback and handle the conversion manually.
This commit is contained in:
@@ -7,5 +7,8 @@ from . import constants
|
||||
|
||||
def get_message_counter(key):
|
||||
"""Return current counter for given key."""
|
||||
rclient = get_redis_connection()
|
||||
return rclient.hget(constants.REDIS_HASHNAME, key)
|
||||
rclient = get_redis_connection(hget_return_type=None)
|
||||
value = rclient.hget(constants.REDIS_HASHNAME, key)
|
||||
if value is None:
|
||||
return None
|
||||
return int(value)
|
||||
|
||||
Reference in New Issue
Block a user