diff --git a/offlineimap/folder/GmailMaildir.py b/offlineimap/folder/GmailMaildir.py index 894792d..a8b607a 100644 --- a/offlineimap/folder/GmailMaildir.py +++ b/offlineimap/folder/GmailMaildir.py @@ -159,7 +159,7 @@ class GmailMaildirFolder(MaildirFolder): content = self.deletemessageheaders(content, self.labelsheader) content = self.addmessageheader(content, '\n', self.labelsheader, labels_str) - rtime = self.messagelist[uid].get('rtime', None) + mtime = long(os.stat(filepath).st_mtime) # write file with new labels to a unique file in tmp messagename = self.new_message_filename(uid, set()) @@ -174,8 +174,9 @@ class GmailMaildirFolder(MaildirFolder): (tmppath, filepath, e[1]), OfflineImapError.ERROR.FOLDER), \ None, exc_info()[2] - if rtime != None: - os.utime(filepath, (rtime, rtime)) + # if utime_from_header=true, we don't want to change the mtime. + if self.utime_from_header and mtime: + os.utime(filepath, (mtime, mtime)) # save the new mtime and labels self.messagelist[uid]['mtime'] = long(os.stat(filepath).st_mtime)