Commit 87d7b358 authored by Martin Matějek's avatar Martin Matějek

Refactor notification files loading from disk

Load only .json files and ignore the rest
parent 9cd8e82a
......@@ -54,14 +54,13 @@ class NotificationStorage:
logger.debug("Deserializing notifications from '%s'", storage_dir)
for _, _, files in os.walk(storage_dir):
for f in files:
filepath = os.path.join(storage_dir, f)
logger.debug("File %s", filepath)
if not f.startswith('.') and f.endswith('.json'):
filepath = os.path.join(storage_dir, f)
n = Notification.from_file(filepath)
n = Notification.from_file(filepath)
if n:
self.notifications[n.notif_id] = n
self.shortid_map[n.notif_id[:self.SHORTID_LENGTH]] = n.notif_id
if n:
self.notifications[n.notif_id] = n
self.shortid_map[n.notif_id[:self.SHORTID_LENGTH]] = n.notif_id
def valid_id(self, msgid):
"""Check if msgid is valid and message with that id exists"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment