From 5526801f3087b210fddbdf36f699ffeb7c40f3d9 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Thu, 27 Mar 2025 07:45:35 +0200 Subject: [PATCH] add debug --- backup_imap/backup_imap.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/backup_imap/backup_imap.py b/backup_imap/backup_imap.py index 1baa573..3f65664 100644 --- a/backup_imap/backup_imap.py +++ b/backup_imap/backup_imap.py @@ -106,13 +106,15 @@ class BackupImap: try: search_response, search_data = self.imap.search('UTF-8', 'UNDELETED') search_succeeded = True - except Exception as error: - imaplib._MAXLINE += 10000 - self._log.debug( - "Error searching mailbox, increasing maxline to %s. %s", - imaplib._MAXLINE, - error - ) + except imaplib.IMAP4.error as error: + error_str = f"{error.__str__}" + if 'got more than' in error_str: + imaplib._MAXLINE += 10000 + self._log.debug( + "Error searching mailbox, increasing maxline to %s. %s", + imaplib._MAXLINE, + error + ) if search_response == 'OK': all_msgs_uids = search_data[0].split() self._log.debug( @@ -179,6 +181,10 @@ class BackupImap: message_path, error ) + else: + self._log.debug( + "Skipping already backed up message" + ) def _backedup_message(self, message_id, mailbox): for message in self.data['backedup_messages']: