From 11a8f8cf9e12587984c9742934394c59b486ec61 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Tue, 21 Oct 2025 16:49:23 +0200 Subject: [PATCH] try fix CI --- chatmaild/src/chatmaild/expire.py | 4 ++++ chatmaild/src/chatmaild/tests/test_expire.py | 8 +++++++- cmdeploy/src/cmdeploy/__init__.py | 7 ++++++- cmdeploy/src/cmdeploy/service/chatmail-expire.timer.f | 1 - 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/chatmaild/src/chatmaild/expire.py b/chatmaild/src/chatmaild/expire.py index 28a6f45b..30a10547 100644 --- a/chatmaild/src/chatmaild/expire.py +++ b/chatmaild/src/chatmaild/expire.py @@ -18,6 +18,10 @@ FileEntry = namedtuple("FileEntry", ("relpath", "mtime", "size")) def iter_mailboxes(basedir, maxnum): + if not os.path.exists(basedir): + print_info(f"no mailboxes found at: {basedir}") + return + for name in os.listdir(basedir)[:maxnum]: if "@" in name: yield MailboxStat(basedir + "/" + name) diff --git a/chatmaild/src/chatmaild/tests/test_expire.py b/chatmaild/src/chatmaild/tests/test_expire.py index 0a7f68e2..be6cc642 100644 --- a/chatmaild/src/chatmaild/tests/test_expire.py +++ b/chatmaild/src/chatmaild/tests/test_expire.py @@ -6,7 +6,7 @@ from pathlib import Path import pytest -from chatmaild.expire import FileEntry, MailboxStat +from chatmaild.expire import FileEntry, MailboxStat, iter_mailboxes from chatmaild.expire import main as expiry_main from chatmaild.fsreport import main as report_main @@ -51,6 +51,12 @@ def test_filentry_ordering(tmp_path): assert l == sorted +def test_no_mailbxoes(tmp_path, capsys): + assert [] == list(iter_mailboxes(str(tmp_path.joinpath("notexists")), maxnum=10)) + out, err = capsys.readouterr() + assert "no mailboxes" in err + + def test_stats_mailbox(mbox1): password = Path(mbox1.basedir).joinpath("password") assert mbox1.last_login == password.stat().st_mtime diff --git a/cmdeploy/src/cmdeploy/__init__.py b/cmdeploy/src/cmdeploy/__init__.py index 8d7af04d..140d6a44 100644 --- a/cmdeploy/src/cmdeploy/__init__.py +++ b/cmdeploy/src/cmdeploy/__init__.py @@ -153,11 +153,16 @@ def _install_remote_venv_with_chatmaild(config) -> None: dest=f"/etc/systemd/system/{basename}", **root_owned, ) + if fn == "chatmail-expire" or fn == "chatmail-fsreport": + # don't auto-start but let the corresponding timer trigger execution + enabled = False + else: + enabled = True systemd.service( name=f"Setup {basename}", service=basename, running=True, - enabled=True, + enabled=enabled, restarted=True, daemon_reload=True, ) diff --git a/cmdeploy/src/cmdeploy/service/chatmail-expire.timer.f b/cmdeploy/src/cmdeploy/service/chatmail-expire.timer.f index 9ae7119f..9520a67c 100644 --- a/cmdeploy/src/cmdeploy/service/chatmail-expire.timer.f +++ b/cmdeploy/src/cmdeploy/service/chatmail-expire.timer.f @@ -3,7 +3,6 @@ Description=Run Daily chatmail-expire job [Timer] OnCalendar=*-*-* 00:02:00 -Persistent=true [Install] WantedBy=timers.target