Re: [PATCH] Sync INTERNALDATE <-> mtime
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Sat, Aug 19, 2006 at 07:20:38PM -0500, Aaron Schrab wrote:
> The attached patch adds syncing the INTERNALDATE of IMAP folders with
> the mtime of messages in maildir folders.
> I want this to happen, because I'm running a dovecot over the maildirs
> synced by offlineimap, and that uses the mtime as the INTERNALDATE.
> When using mutt to view messages I generally sort based on the received
> date, which for IMAP folders is the INTERNALDATE.
>
> Since this is the first real coding I've done in Python the patch may
> need to be cleaned up some, but it's working pretty well for me. I've
> added new messages to each side, and the received date has been
> preserved going both ways.
I have checked this patch into my Darcs tree, followed by this patch to
gracefully fall back using the former mechanism. THANKS for
contributing code!
Mon Aug 21 15:13:39 CDT 2006 John Goerzen <jgoerzen@xxxxxxxxxxxx>
* Fix up date parsing to use message date if no rtime is available
diff -rN -u old-offlineimap/offlineimap/folder/IMAP.py
new-offlineimap/offlineimap/folder/IMAP.py
--- old-offlineimap/offlineimap/folder/IMAP.py 2006-08-21 15:16:30.309321543
-0500
+++ new-offlineimap/offlineimap/folder/IMAP.py 2006-08-21 15:16:30.313321796
-0500
@@ -197,9 +197,15 @@
# This backend always assigns a new uid, so the uid arg is ignored.
# In order to get the new uid, we need to save off the message ID.
+ message = rfc822.Message(StringIO(content))
+ datetuple_msg = rfc822.parsedate(message.getheader('Date'))
+ # Will be None if missing or not in a valid format.
+
# If time isn't known
- if rtime == None:
+ if rtime == None and datetuple_msg == None:
datetuple = time.localtime()
+ elif rtime == None:
+ datetuple = datetuple_msg
else:
datetuple = time.localtime(rtime)
|
|