Fix exporter: correct --dir flag, handle full prompt sequence, find mail_* dir

- Replace --export-dir (doesn't exist) with --dir (correct v1.0.6 flag)
- Add handlers for the operation prompt (send 'B') and 'Do you wish to
  proceed?' (send 'Yes') which were previously unhandled
- After export, locate the actual mail_<timestamp> directory the CLI creates
  under <base>/<Email>/ and return it so callers get the right path
- Update prompt pattern for 'Username:' (CLI uses 'Username' not 'Email')
- _clean_export_dir now uses shutil.rmtree since the returned path is the
  mail_* subdir, not a flat file directory

https://claude.ai/code/session_01KjaNo9RXevw6x1DjJD8mj6
This commit is contained in:
Claude
2026-03-24 22:06:05 +00:00
parent 69c685798c
commit 83eb9752a5
2 changed files with 105 additions and 48 deletions
+7 -6
View File
@@ -384,12 +384,13 @@ def _load_config() -> dict:
def _clean_export_dir(export_dir: Path) -> None:
"""Delete all files in the export directory after a sync cycle."""
for f in export_dir.iterdir():
try:
f.unlink()
except OSError as exc:
log.warning("Could not delete export file %s: %s", f.name, exc)
"""Remove the mail_* export directory tree after a sync cycle."""
import shutil
try:
shutil.rmtree(export_dir)
log.debug("Removed export directory: %s", export_dir.name)
except OSError as exc:
log.warning("Could not remove export directory %s: %s", export_dir.name, exc)
# ---------------------------------------------------------------------------