mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-25 18:40:06 -04:00
No longer restricting the Controller from unmounting the wrolpi drive.
This commit is contained in:
parent
eef1225bb4
commit
c6c0960613
2 changed files with 1 additions and 32 deletions
|
|
@ -13,7 +13,7 @@ from dataclasses import dataclass
|
|||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from controller.lib.config import get_config, is_docker_mode
|
||||
from controller.lib.config import is_docker_mode
|
||||
|
||||
SUPPORTED_FILESYSTEMS = {"ext4", "btrfs", "vfat", "exfat"}
|
||||
|
||||
|
|
@ -204,29 +204,6 @@ def unmount_drive(mount_point: str, lazy: bool = False) -> dict:
|
|||
if is_docker_mode():
|
||||
return {"success": False, "error": "Not available in Docker mode"}
|
||||
|
||||
# Safety rule: Don't unmount /media/wrolpi if no drives configured
|
||||
if mount_point == "/media/wrolpi":
|
||||
config = get_config()
|
||||
configured_mounts = config.get("drives", {}).get("mounts", [])
|
||||
|
||||
if not configured_mounts:
|
||||
return {
|
||||
"success": False,
|
||||
"error": "Cannot unmount /media/wrolpi: No drives are configured. "
|
||||
"This prevents accidental data loss.",
|
||||
}
|
||||
|
||||
# Check if this is the primary drive
|
||||
primary_mount = next(
|
||||
(m for m in configured_mounts if m.get("is_primary")),
|
||||
None
|
||||
)
|
||||
if primary_mount:
|
||||
return {
|
||||
"success": False,
|
||||
"error": "Cannot unmount /media/wrolpi: This is the primary WROLPi drive.",
|
||||
}
|
||||
|
||||
# Check if mount is busy
|
||||
if is_mount_busy(mount_point) and not lazy:
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -293,14 +293,6 @@ class TestUnmountDrive:
|
|||
assert result["success"] is False
|
||||
assert "Docker" in result["error"]
|
||||
|
||||
def test_protects_primary_wrolpi_mount(self):
|
||||
"""Should protect /media/wrolpi from accidental unmount."""
|
||||
with mock.patch("controller.lib.disks.is_docker_mode", return_value=False):
|
||||
with mock.patch("controller.lib.disks.get_config", return_value={"drives": {}}):
|
||||
result = unmount_drive("/media/wrolpi")
|
||||
assert result["success"] is False
|
||||
assert "Cannot unmount /media/wrolpi" in result["error"]
|
||||
|
||||
def test_unmounts_successfully(self):
|
||||
"""Should unmount successfully."""
|
||||
with mock.patch("controller.lib.disks.is_docker_mode", return_value=False):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue