From 208604be4f4dc97ca07adf61863263d449b1072c Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Fri, 28 Mar 2025 10:57:35 +0200 Subject: [PATCH] Restrict more the dates --- backup_imap/backup_imap.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backup_imap/backup_imap.py b/backup_imap/backup_imap.py index 45c3d7c..93c7193 100644 --- a/backup_imap/backup_imap.py +++ b/backup_imap/backup_imap.py @@ -101,8 +101,10 @@ class BackupImap: os.mkdir(mailbox_path) current = time.gmtime() # One year at a time because big mailboxes will take all memory due to Python IMAP library memory handling + previous_year=1970 for year in range(current.tm_year-10, current.tm_year+1): - search_response, search_data = self.imap.search('UTF-8', f'(BEFORE "1-Jan-{year}")') + search_response, search_data = self.imap.search('UTF-8', f'(SINCE "1-Jan-{previous_year}" BEFORE "1-Jan-{year}")') + previous_year = year if search_response == 'OK': all_msgs_uids = search_data[0].split() self._log.debug(