folder: Maildir: actually try to use Delivery-Date if Date is broken
This value is used to set the timestamp prefix in the filename. Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
		@@ -366,12 +366,13 @@ class MaildirFolder(BaseFolder):
 | 
				
			|||||||
        # Use the mail timestamp given by either Date or Delivery-date mail
 | 
					        # Use the mail timestamp given by either Date or Delivery-date mail
 | 
				
			||||||
        # headers.
 | 
					        # headers.
 | 
				
			||||||
        message_timestamp = None
 | 
					        message_timestamp = None
 | 
				
			||||||
        if self._filename_use_mail_timestamp:
 | 
					        if self._filename_use_mail_timestamp is not False:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                message_timestamp = emailutil.get_message_date(content, 'Date')
 | 
					                message_timestamp = emailutil.get_message_date(content, 'Date')
 | 
				
			||||||
                if message_timestamp is None:
 | 
					                if message_timestamp is None:
 | 
				
			||||||
                    # Give a try with Delivery-date
 | 
					                    # Give a try with Delivery-date
 | 
				
			||||||
                    date = emailutil.get_message_date(content, 'Delivery-date')
 | 
					                    message_timestamp = emailutil.get_message_date(
 | 
				
			||||||
 | 
					                            content, 'Delivery-date')
 | 
				
			||||||
            except Exception as e:
 | 
					            except Exception as e:
 | 
				
			||||||
                # This should never happen.
 | 
					                # This should never happen.
 | 
				
			||||||
                from email.Parser import Parser
 | 
					                from email.Parser import Parser
 | 
				
			||||||
@@ -381,8 +382,8 @@ class MaildirFolder(BaseFolder):
 | 
				
			|||||||
                ui.warn("UID %d has invalid date %s: %s\n"
 | 
					                ui.warn("UID %d has invalid date %s: %s\n"
 | 
				
			||||||
                    "Not using message timestamp as file prefix"%
 | 
					                    "Not using message timestamp as file prefix"%
 | 
				
			||||||
                    (uid, datestr, e))
 | 
					                    (uid, datestr, e))
 | 
				
			||||||
                # No need to check if date is None here since it would
 | 
					                # No need to check if message_timestamp is None here since it
 | 
				
			||||||
                # be overridden by _gettimeseq.
 | 
					                # would be overridden by _gettimeseq.
 | 
				
			||||||
        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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user