diff --git a/coe_mirror.py b/coe_mirror.py index 393af89..166bddb 100644 --- a/coe_mirror.py +++ b/coe_mirror.py @@ -168,13 +168,16 @@ def release_lock(lock_fd: int) -> None: def probe_target() -> bool: - """Probe target directory health. Write tiny file, read back, delete. Return True if healthy.""" + """Probe target directory health. Write tiny file, read back, delete. Return True if healthy. + + When MOUNT_ROOT is configured, first verify it is a live mountpoint and TARGET_DIR is under it; return False (queue to pending) otherwise. + """ try: if MOUNT_ROOT is not None: if not MOUNT_ROOT.exists() or not os.path.ismount(str(MOUNT_ROOT)): logger.warning("mount_root %s is not a live mountpoint; target unavailable; queuing locally", MOUNT_ROOT) return False - if not (TARGET_DIR == MOUNT_ROOT or TARGET_DIR.is_relative_to(MOUNT_ROOT)): + if not TARGET_DIR.is_relative_to(MOUNT_ROOT): logger.warning("target_dir %s is not under configured mount_root %s; misconfig; queuing locally", TARGET_DIR, MOUNT_ROOT) return False diff --git a/tests/test_coe_mirror.py b/tests/test_coe_mirror.py index 4b74b2e..1a3f027 100644 --- a/tests/test_coe_mirror.py +++ b/tests/test_coe_mirror.py @@ -37,6 +37,7 @@ def mock_paths(tmp_path, monkeypatch): pending_dir.mkdir() log_dir.mkdir() + monkeypatch.setattr(coe_mirror, "MOUNT_ROOT", None) monkeypatch.setattr(coe_mirror, "TARGET_DIR", target_dir) monkeypatch.setattr(coe_mirror, "PENDING_DIR", pending_dir) monkeypatch.setattr(coe_mirror, "LOG_DIR", log_dir)