<DKIM> maxage causes loss of local email

Janna Martl janna.martl109 at gmail.com
Fri Mar 6 07:52:28 GMT 2015


Oops, corrected:

On Thu, Mar 05, 2015 at 10:30:23PM -0500, Janna Martl wrote:
>--- /usr/lib/python2.7/site-packages/offlineimap/folder/Maildir.py	2015-03-05 22:13:10.390450915 -0500
>+++ Maildir.py	2015-03-05 22:13:53.882540931 -0500
>@@ -22,6 +22,7 @@
> import tempfile
> from .Base import BaseFolder
> from threading import Lock
>+from offlineimap import emailutil
>
> try:
>     from hashlib import md5
>@@ -235,16 +236,25 @@
>         filepath = os.path.join(self.getfullname(), filename)
>         return os.path.getmtime(filepath)
>
>-    def new_message_filename(self, uid, flags=set()):
>+    def new_message_filename(self, uid, flags=set(), rtime=None):
>         """Creates a new unique Maildir filename
>
>         :param uid: The UID`None`, or a set of maildir flags
>         :param flags: A set of maildir flags
>         :returns: String containing unique message filename"""
>-        timeval, timeseq = _gettimeseq()
>-        return '%d_%d.%d.%s,U=%d,FMD5=%s%s2,%s' % \
>-            (timeval, timeseq, os.getpid(), socket.gethostname(),
>-             uid, self._foldermd5, self.infosep, ''.join(sorted(flags)))
>+        if rtime is None:
>+            timeval, timeseq = _gettimeseq()
>+        else:
>+            timeval, timeseq = rtime, 0
>+        filename = '%d_%d.%d.%s,U=%d,FMD5=%s%s2,%s' % \
>+                (timeval, timeseq, os.getpid(), socket.gethostname(),
>+                 uid, self._foldermd5, self.infosep, ''.join(sorted(flags)))
>+        while os.path.exists(os.path.join(self.getfullname(), "cur", filename)) or os.path.exists(os.path.join(self.getfullname(), "new", filename)):
>+            timeseq += 1
>+            filename = '%d_%d.%d.%s,U=%d,FMD5=%s%s2,%s' % \
>+                    (timeval, timeseq, os.getpid(), socket.gethostname(),
>+                     uid, self._foldermd5, self.infosep, ''.join(sorted(flags)))
>+        return filename
>
>
>     def save_to_tmp_file(self, filename, content):
>@@ -314,7 +324,9 @@
>         # Otherwise, save the message in tmp/ and then call savemessageflags()
>         # to give it a permanent home.
>         tmpdir = os.path.join(self.getfullname(), 'tmp')
>-        messagename = self.new_message_filename(uid, flags)
>+        if rtime is None:
>+            rtime = emailutil.get_message_date(content)
>+        messagename = self.new_message_filename(uid, flags, rtime=rtime)
>         tmpname = self.save_to_tmp_file(messagename, content)
>         if rtime != None:
>             os.utime(os.path.join(self.getfullname(), tmpname), (rtime, rtime))
>@@ -382,8 +394,10 @@
>         oldfilename = self.messagelist[uid]['filename']
>         dir_prefix, filename = os.path.split(oldfilename)
>         flags = self.getmessageflags(uid)
>+        content = self.getmessage(uid)
>+        rtime = emailutil.get_message_date(content)
>         newfilename = os.path.join(dir_prefix,
>-          self.new_message_filename(new_uid, flags))
>+          self.new_message_filename(new_uid, flags, rtime=rtime))
>         os.rename(os.path.join(self.getfullname(), oldfilename),
>                   os.path.join(self.getfullname(), newfilename))
>         self.messagelist[new_uid] = self.messagelist[uid]





More information about the OfflineIMAP-project mailing list