Commit graph

5 commits

Author SHA1 Message Date
05f2e6c870 Fail script on all server errors
Remove local exception handling for IMAP operations to ensure script
exits on any server failure (e.g., auth, connection, search errors).
This allows systemd OnFailure to notify on fixable issues.

Changes:
- Remove try-except in check_duplicate, sync_folder, sync_all_folders
- Let IMAP exceptions propagate to main() for exit(1)
2026-01-04 20:10:33 +09:00
69ec294a56 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
2026-01-04 20:03:49 +09:00
a32f79980e Implement configurable STATE_DIR for state files
Move processed_message_ids.txt and last_run.txt to STATE_DIR,
configurable via .env. Install script creates ./state by default.

Changes:
- Add STATE_DIR to .env.example and config loading
- Update EmailForwarder to use os.path.join for file paths
- Add os.makedirs for state dir creation
- Update README with STATE_DIR option
2026-01-04 19:45:48 +09:00
d9cbf829bb Fix calls to private connect/disconnect methods
Change remaining .connect() and .disconnect() calls to private
._connect() and ._disconnect() after removing public methods.

Changes:
- Update EmailForwarder.sync_all_folders to use _connect/_disconnect
2026-01-04 19:19:38 +09:00
c96bd8ed71 Restructure as runnable Python module
Convert email_forwarder.py to a package with __main__.py for module execution.
Update systemd service to use -m email_forwarder.
Configure pyproject.toml to exclude state/ from packaging.

Changes:
- Create email_forwarder/ package with __init__.py and __main__.py
- Move main script to email_forwarder/email_forwarder.py
- Update ExecStart to python -m email_forwarder
- Add setuptools config to exclude state/ directory
2026-01-04 18:22:42 +09:00
Renamed from email_forwarder.py (Browse further)