update
This commit is contained in:
20
main.py
20
main.py
@@ -713,18 +713,13 @@ def move_message(imap_conn, msg_id, target_folder):
|
||||
# označíme původní zprávu jako zpracovanou
|
||||
mark_processed(imap_conn, msg_id)
|
||||
|
||||
# neoznačujeme jako \Seen, jen mažeme ze source folderu
|
||||
# neoznačujeme jako \Seen, jen přidáme \Deleted
|
||||
typ, data = imap_conn.store(msg_id, "+FLAGS", "\\Deleted")
|
||||
if typ != "OK":
|
||||
logger.error(f"Failed to mark message {msg_id_str} as deleted: {data}")
|
||||
return
|
||||
|
||||
typ, data = imap_conn.expunge()
|
||||
if typ != "OK":
|
||||
logger.error(f"Failed to expunge after moving message {msg_id_str}: {data}")
|
||||
return
|
||||
|
||||
logger.info(f"Message {msg_id_str} moved to {target_folder} and expunged from INBOX")
|
||||
logger.info(f"Message {msg_id_str} marked as deleted in INBOX (will be expunged later)")
|
||||
|
||||
|
||||
# ---------- Main processing ----------
|
||||
@@ -762,10 +757,19 @@ def process_once():
|
||||
except Exception as e:
|
||||
logger.error(f"Error moving message {msg_id_str} to {target_folder}: {e}")
|
||||
logger.debug(traceback.format_exc())
|
||||
# move selhal, ale mark_processed už uvnitř běžel,
|
||||
# move selhal, ale mark_processed už uvnitř běžel (nebo proběhne příště),
|
||||
# takže se zpráva nebude dál klasifikovat
|
||||
continue
|
||||
|
||||
# Po zpracování všech zpráv provedeme jedno společné EXPUNGE
|
||||
logger.info("Running single EXPUNGE for all deleted messages in INBOX")
|
||||
try:
|
||||
typ, data = imap_conn.expunge()
|
||||
if typ != "OK":
|
||||
logger.error(f"EXPUNGE failed: {data}")
|
||||
except Exception as e:
|
||||
logger.warning(f"EXPUNGE raised an exception: {e}")
|
||||
|
||||
finally:
|
||||
logger.info("Logging out from IMAP")
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user