Isolate mock_paths fixture from host MOUNT_ROOT config; simplify probe_target mount check

mock_paths patched TARGET_DIR/PENDING_DIR/etc but not MOUNT_ROOT, so tests leaked the host's real ~/pCloudDrive mount_root config and failed probe_target's mountpoint check. Also drop redundant equality clause since is_relative_to already covers equal paths, and document the mount precondition.
This commit is contained in:
n0mad1k
2026-07-10 14:40:36 -04:00
parent 2853d2e125
commit 9fd114d1b0
2 changed files with 6 additions and 2 deletions
+5 -2
View File
@@ -168,13 +168,16 @@ def release_lock(lock_fd: int) -> None:
def probe_target() -> bool: 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: try:
if MOUNT_ROOT is not None: if MOUNT_ROOT is not None:
if not MOUNT_ROOT.exists() or not os.path.ismount(str(MOUNT_ROOT)): 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) logger.warning("mount_root %s is not a live mountpoint; target unavailable; queuing locally", MOUNT_ROOT)
return False 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) logger.warning("target_dir %s is not under configured mount_root %s; misconfig; queuing locally", TARGET_DIR, MOUNT_ROOT)
return False return False
+1
View File
@@ -37,6 +37,7 @@ def mock_paths(tmp_path, monkeypatch):
pending_dir.mkdir() pending_dir.mkdir()
log_dir.mkdir() log_dir.mkdir()
monkeypatch.setattr(coe_mirror, "MOUNT_ROOT", None)
monkeypatch.setattr(coe_mirror, "TARGET_DIR", target_dir) monkeypatch.setattr(coe_mirror, "TARGET_DIR", target_dir)
monkeypatch.setattr(coe_mirror, "PENDING_DIR", pending_dir) monkeypatch.setattr(coe_mirror, "PENDING_DIR", pending_dir)
monkeypatch.setattr(coe_mirror, "LOG_DIR", log_dir) monkeypatch.setattr(coe_mirror, "LOG_DIR", log_dir)