summaryrefslogtreecommitdiff
path: root/distixlib/plugins/import_mail_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'distixlib/plugins/import_mail_plugin.py')
-rw-r--r--distixlib/plugins/import_mail_plugin.py20
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