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:
+5
-2
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user