diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-03-25 13:12:24 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-03-25 14:32:59 +0200 |
commit | 22b4825f3fc5653f5d1064df86d05582c37e85ac (patch) | |
tree | 0a880015945053f4af3ac7f749a0900e428462fe | |
parent | b264520f1baf681f05fb837f82c11a57ae5256d3 (diff) | |
download | distix-22b4825f3fc5653f5d1064df86d05582c37e85ac.tar.gz |
Maintain and user msg id cache
-rw-r--r-- | distixlib/plugins/import_mail_plugin.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/distixlib/plugins/import_mail_plugin.py b/distixlib/plugins/import_mail_plugin.py index 6e3fb84..2bf9586 100644 --- a/distixlib/plugins/import_mail_plugin.py +++ b/distixlib/plugins/import_mail_plugin.py @@ -141,14 +141,18 @@ class ImportMailPlugin(cliapp.Plugin): msg_ids = self._get_message_ids(msg) for ticket_id in all_ticket_ids: - filenames = store.get_message_filenames(ticket_id) - for filename in filenames: - with open(filename) as f: - other_msg = email.message_from_file(f) - other_ids = self._get_message_ids(other_msg) - if other_ids.intersection(msg_ids): - ticket = store.get_ticket(ticket_id) - tickets.append(ticket) + if ticket_id in cache: + other_ids = cache.get_msg_ids_for_ticket_id(ticket_id) + else: + filenames = store.get_message_filenames(ticket_id) + for filename in filenames: + with open(filename) as f: + other_msg = email.message_from_file(f) + other_ids = self._get_message_ids(other_msg) + cache.add_msg_ids_for_ticket_id(ticket_id, other_ids) + if other_ids.intersection(msg_ids): + ticket = store.get_ticket(ticket_id) + tickets.append(ticket) return tickets |