handle maxline

This commit is contained in:
Antonio J. Delgado 2025-03-27 07:36:34 +02:00
parent 37cb1d9423
commit 1f04a016a3

View file

@ -101,7 +101,18 @@ class BackupImap:
os.mkdir(os.path.dirname(mailbox_path))
if not os.path.exists(mailbox_path):
os.mkdir(mailbox_path)
search_response, search_data = self.imap.search('UTF-8', 'UNDELETED')
search_succeeded = False
while not search_succeeded:
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
)
if search_response == 'OK':
all_msgs_uids = search_data[0].split()
self._log.debug(