[PATCH 1/2] decouple utime_from_header from rtime

Abdo Roig-Maranges abdo.roig at gmail.com
Thu Apr 2 13:41:47 BST 2015


We were using rtime for two different purposes:
- to store remote internal date
- to use in the utime_from_header option

Let's decouple the utime_from_header logic from rtime, now rtime means
remote internal date.

Signed-off-by: Abdo Roig-Maranges <abdo.roig at gmail.com>
---
 offlineimap/folder/Base.py    | 6 ------
 offlineimap/folder/Maildir.py | 7 +++++--
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
index 16b5819..5d81af4 100644
--- a/offlineimap/folder/Base.py
+++ b/offlineimap/folder/Base.py
@@ -692,9 +692,6 @@ class BaseFolder(object):
             message = None
             flags = self.getmessageflags(uid)
             rtime = self.getmessagetime(uid)
-            if dstfolder.utime_from_header:
-                content = self.getmessage(uid)
-                rtime = emailutil.get_message_date(content, 'Date')
 
             # If any of the destinations actually stores the message body,
             # load it up.
@@ -766,9 +763,6 @@ class BaseFolder(object):
                 # dst has message with that UID already, only update status
                 flags = self.getmessageflags(uid)
                 rtime = self.getmessagetime(uid)
-                if dstfolder.utime_from_header:
-                    content = self.getmessage(uid)
-                    rtime = emailutil.get_message_date(content, 'Date')
                 statusfolder.savemessage(uid, None, flags, rtime)
                 continue
 
diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py
index 79c34a7..f1b8e8e 100644
--- a/offlineimap/folder/Maildir.py
+++ b/offlineimap/folder/Maildir.py
@@ -324,8 +324,11 @@ class MaildirFolder(BaseFolder):
         tmpdir = os.path.join(self.getfullname(), 'tmp')
         messagename = self.new_message_filename(uid, flags)
         tmpname = self.save_to_tmp_file(messagename, content)
-        if rtime != None:
-            os.utime(os.path.join(self.getfullname(), tmpname), (rtime, rtime))
+
+        if self.utime_from_header:
+            date = emailutil.get_message_date(content, 'Date')
+            if date != None:
+                os.utime(os.path.join(self.getfullname(), tmpname), (date, date))
 
         self.messagelist[uid] = self.msglist_item_initializer(uid)
         self.messagelist[uid]['flags'] = flags
-- 
2.3.5





More information about the OfflineIMAP-project mailing list