Skip to content

Commit

Permalink
Avoid reloading message from disk if we already have it in RAM
Browse files Browse the repository at this point in the history
  • Loading branch information
BjarniRunar committed Oct 23, 2014
1 parent 1ef3c99 commit d1000ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mailpile/mail_source/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def _copy_new_messages(self, mbx_key, mbx_cfg,
# This forks off a scan job to index the message
config.index.scan_one_message(
session, mbx_key, loc, loc_key,
wait=False, **scan_args)
wait=False, msg_data=data, **scan_args)

stop_after -= 1
if stop_after == 0:
Expand Down
8 changes: 6 additions & 2 deletions mailpile/search.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import cStringIO
import email
import lxml.html
import re
Expand Down Expand Up @@ -701,7 +702,7 @@ def scan_one_message(self, session, mailbox_idx, mbox, msg_mbox_key,

def _real_scan_one(self, session,
mailbox_idx, mbox, msg_mbox_idx,
msg_ptr=None, last_date=None,
msg_ptr=None, msg_data=None, last_date=None,
process_new=None, apply_tags=None, stop_after=None,
editable=False, event=None, progress=None):
added = updated = 0
Expand All @@ -714,7 +715,10 @@ def _real_scan_one(self, session,
session.ui.debug('Reading message %s/%s'
% (mailbox_idx, msg_mbox_idx))
try:
msg_fd = mbox.get_file(msg_mbox_idx)
if msg_data:
msg_fd = cStringIO.StringIO(msg_data)
else:
msg_fd = mbox.get_file(msg_mbox_idx)
msg = ParseMessage(msg_fd,
pgpmime=session.config.prefs.index_encrypted,
config=session.config)
Expand Down

0 comments on commit d1000ef

Please sign in to comment.