Fix duplicate detection by ensuring folder selection
Call ensure_folder_exists before check_duplicate to select the dest folder, allowing IMAP SEARCH to work in SELECTED state. Changes: - Move dest.ensure_folder_exists(folder) before check_duplicate in process_email - Add logging to check_duplicate for debugging
This commit is contained in:
parent
a0f40a1327
commit
69ec294a56
1 changed files with 8 additions and 1 deletions
|
|
@ -106,8 +106,10 @@ class DestImap(ImapClient):
|
|||
"""Check if Message-ID exists in current folder."""
|
||||
try:
|
||||
results = self._search(f'HEADER Message-ID "{msg_id}"')
|
||||
logging.debug(f"Check duplicate for {msg_id}: found {len(results)} matches")
|
||||
return len(results) > 0
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.error(f"Error checking duplicate for {msg_id}: {e}")
|
||||
return False
|
||||
|
||||
def _create_folder(self, folder: str):
|
||||
|
|
@ -205,6 +207,11 @@ class EmailForwarder:
|
|||
continue
|
||||
if msg_id in self.processed_ids:
|
||||
continue
|
||||
self.dest.ensure_folder_exists(folder)
|
||||
if self.dest.check_duplicate(msg_id):
|
||||
continue
|
||||
if msg_id in self.processed_ids:
|
||||
continue
|
||||
if self.dest.check_duplicate(msg_id):
|
||||
continue
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue