~bloodearnest/localmail/trunk

« back to all changes in this revision

Viewing changes to localmail/inbox.py

  • Committer: Simon Davy
  • Date: 2015-10-14 13:24:14 UTC
  • Revision ID: simon.davy@canonical.com-20151014132414-l18jbutu2wln3vwe
don't flush every 5s, just flush on edit

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from zope.interface import implements
26
26
 
27
27
from twisted.mail import imap4
28
 
from twisted.internet import reactor
29
28
from twisted.python import log
30
29
 
31
30
UID_GENERATOR = count()
59
58
        if self.mbox is not None:
60
59
            self.mbox.add(msg.msg)
61
60
        self.msgs.append(msg)
 
61
        self.flush()
62
62
 
63
63
    def setFile(self, path):
64
64
        log.msg("creating mbox file %s" % path)
65
65
        self.mbox = mailbox.mbox(path)
66
 
        reactor.callLater(5, self.flush)
67
66
 
68
67
    def flush(self):
69
68
        if self.mbox is not None:
70
69
            log.msg("flushing mailbox")
71
70
            self.mbox.flush()
72
 
            reactor.callLater(5, self.flush)
73
71
 
74
72
    def __init__(self):
75
73
        # can't use OrderedDict as need to support 2.6 :(
156
154
                # use less efficient remove() because the indexes are changing
157
155
                self.msgs.remove(msg)
158
156
                removed.append(msg.uid)
 
157
        self.flush()
159
158
        return removed
160
159
 
161
160
    def destroy(self):