minor changes

This commit is contained in:
Cyberes 2024-03-06 13:48:06 -07:00
parent ebadffecc4
commit d36da567ef
2 changed files with 4 additions and 3 deletions

View File

@ -8,6 +8,7 @@ attachments_path: attachments
exclude_folders: exclude_folders:
- Trash - Trash
- Drafts - Drafts
- Spam
- '[Gmail]/Trash' - '[Gmail]/Trash'
- '[Gmail]/Drafts' - '[Gmail]/Drafts'
- '[Gmail]/Starred' - '[Gmail]/Starred'

View File

@ -2,7 +2,6 @@ import concurrent.futures
import email import email
import imaplib import imaplib
import logging import logging
import sys
from email.header import decode_header from email.header import decode_header
from email.utils import parsedate_to_datetime from email.utils import parsedate_to_datetime
from json import JSONEncoder from json import JSONEncoder
@ -53,7 +52,7 @@ class MailConnection:
detected = chardet.detect(raw_email_bytes) detected = chardet.detect(raw_email_bytes)
except TypeError as e: except TypeError as e:
self.logger.critical(f'Failed to decode an email. Timeout? Server error? - "{e}"') self.logger.critical(f'Failed to decode an email. Timeout? Server error? - "{e}"')
sys.exit(1) return
encoding = detected['encoding'] encoding = detected['encoding']
if not encoding: if not encoding:
encoding = 'utf-8' encoding = 'utf-8'
@ -136,6 +135,7 @@ class MailConnection:
first_email_id = int(id_list[0]) first_email_id = int(id_list[0])
latest_email_id = int(id_list[-1]) latest_email_id = int(id_list[-1])
with concurrent.futures.ThreadPoolExecutor(max_workers=max_threads) as executor: with concurrent.futures.ThreadPoolExecutor(max_workers=max_threads) as executor:
futures = {executor.submit(self.__fetch_email, i) for i in range(latest_email_id, first_email_id, -1)} futures = {executor.submit(self.__fetch_email, i) for i in range(latest_email_id, first_email_id, -1)}
for future in concurrent.futures.as_completed(futures): for future in concurrent.futures.as_completed(futures):