<DKIM> [PATCH] make savemessagelabels honor utime_from_header
Nicolas Sebrecht
nicolas.s-dev at laposte.net
Fri Apr 3 09:22:42 BST 2015
On Fri, Apr 03, 2015 at 03:29:36AM +0200, Abdo Roig-Maranges wrote:
> Previously, syncing labels on a message always resulted in updating the
> file modification time, even with utime_from_headers=true
>
> This patch restores the file mtime to the previous value when
> utime_from_headers=true, preventing a label synchronization from
> breaking the promise that the file mtimes coincide with the header date.
I get what you mean but strictly speacking, we don't "restore the file
mtime". We "avoid changing mtime".
So, utime_from_header is incompatible with quick syncs. Do we forbid
quick sync when utime_from_header is set? Is it documented in
offlineimap.conf?
> Signed-off-by: Abdo Roig-Maranges <abdo.roig at gmail.com>
> ---
> offlineimap/folder/GmailMaildir.py | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> 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))
if (self.utime_from_header != True) and mtime:
>
> # save the new mtime and labels
> self.messagelist[uid]['mtime'] = long(os.stat(filepath).st_mtime)
--
Nicolas Sebrecht
More information about the OfflineIMAP-project
mailing list