folder: utime_from_header is for Maildir only

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2016-05-11 04:10:13 +02:00
parent 12866f2771
commit bf8bfbc872
3 changed files with 11 additions and 14 deletions

View File

@ -507,7 +507,7 @@ localfolders = ~/Test
# example, finding messages older than 3 months), without parsing each # example, finding messages older than 3 months), without parsing each
# file/message content. # file/message content.
# #
# If enabled, this forbid the -q (quick mode) CLI option to work correctly. # If enabled, this prevents the -q (quick mode) CLI option to work correctly.
# #
# Default: no. # Default: no.
# #

View File

@ -54,29 +54,25 @@ class BaseFolder(object):
if self.visiblename == self.getsep(): if self.visiblename == self.getsep():
self.visiblename = '' self.visiblename = ''
repoconfname = "Repository " + repository.name self.repoconfname = "Repository " + repository.name
self.config = repository.getconfig() self.config = repository.getconfig()
utime_from_header_global = self.config.getdefaultboolean(
"general", "utime_from_header", False)
self._utime_from_header = self.config.getdefaultboolean(
repoconfname, "utime_from_header", utime_from_header_global)
# Do we need to use mail timestamp for filename prefix? # Do we need to use mail timestamp for filename prefix?
filename_use_mail_timestamp_global = self.config.getdefaultboolean( filename_use_mail_timestamp_global = self.config.getdefaultboolean(
"general", "filename_use_mail_timestamp", False) "general", "filename_use_mail_timestamp", False)
self._filename_use_mail_timestamp = self.config.getdefaultboolean( self._filename_use_mail_timestamp = self.config.getdefaultboolean(
repoconfname, self.repoconfname,
"filename_use_mail_timestamp", "filename_use_mail_timestamp",
filename_use_mail_timestamp_global) filename_use_mail_timestamp_global)
self._sync_deletes = self.config.getdefaultboolean( self._sync_deletes = self.config.getdefaultboolean(
repoconfname, "sync_deletes", True) self.repoconfname, "sync_deletes", True)
# Determine if we're running static or dynamic folder filtering # Determine if we're running static or dynamic folder filtering
# and check filtering status # and check filtering status
self._dynamic_folderfilter = self.config.getdefaultboolean( self._dynamic_folderfilter = self.config.getdefaultboolean(
repoconfname, "dynamic_folderfilter", False) self.repoconfname, "dynamic_folderfilter", False)
self._sync_this = repository.should_sync_folder(self.ffilter_name) self._sync_this = repository.should_sync_folder(self.ffilter_name)
if self._dynamic_folderfilter: if self._dynamic_folderfilter:
self.ui.debug('', "Running dynamic folder filtering on '%s'[%s]"% self.ui.debug('', "Running dynamic folder filtering on '%s'[%s]"%
@ -115,10 +111,6 @@ class BaseFolder(object):
else: else:
return self.repository.should_sync_folder(self.ffilter_name) return self.repository.should_sync_folder(self.ffilter_name)
@property
def utime_from_header(self):
return self._utime_from_header
def suggeststhreads(self): def suggeststhreads(self):
"""Returns true if this folder suggests using threads for actions; """Returns true if this folder suggests using threads for actions;
false otherwise. Probably only IMAP will return true.""" false otherwise. Probably only IMAP will return true."""

View File

@ -74,6 +74,11 @@ class MaildirFolder(BaseFolder):
self._foldermd5 = md5(self.getvisiblename()).hexdigest() self._foldermd5 = md5(self.getvisiblename()).hexdigest()
# Cache the full folder path, as we use getfullname() very often. # Cache the full folder path, as we use getfullname() very often.
self._fullname = os.path.join(self.getroot(), self.getname()) self._fullname = os.path.join(self.getroot(), self.getname())
# Modification time from 'Date' header.
utime_from_header_global = self.config.getdefaultboolean(
"general", "utime_from_header", False)
self._utime_from_header = self.config.getdefaultboolean(
self.repoconfname, "utime_from_header", utime_from_header_global)
# Interface from BaseFolder # Interface from BaseFolder
def getfullname(self): def getfullname(self):
@ -365,7 +370,7 @@ class MaildirFolder(BaseFolder):
messagename = self.new_message_filename(uid, flags, date=message_timestamp) messagename = self.new_message_filename(uid, flags, date=message_timestamp)
tmpname = self.save_to_tmp_file(messagename, content) tmpname = self.save_to_tmp_file(messagename, content)
if self.utime_from_header: if self._utime_from_header is True:
try: try:
date = emailutil.get_message_date(content, 'Date') date = emailutil.get_message_date(content, 'Date')
if date is not None: if date is not None: