Warning users when files exist in mount location. Users may have accidentally downloaded files into the media directory, we want to warn them.
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run

This commit is contained in:
Roland 2026-05-14 16:38:02 -06:00
parent da340a00b3
commit cd8792f697
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
12 changed files with 482 additions and 34 deletions

View file

@ -14,6 +14,7 @@ from controller.lib.config import (
update_config,
)
from controller.lib.disks import (
check_shadowed_data,
get_block_devices,
get_mounts,
mount_drive,
@ -39,6 +40,10 @@ class MountRequest(BaseModel):
fstype: Optional[str] = Field(default=None, description="Filesystem type (auto-detected if not specified)")
options: str = Field(default="defaults", description="Mount options")
persist: bool = Field(default=False, description="Add to fstab for persistent mounting")
force_shadowed: bool = Field(
default=False,
description="Proceed even if existing data at the mount target would be hidden by the new mount",
)
class UnmountRequest(BaseModel):
@ -98,6 +103,24 @@ async def disk_mount(request: MountRequest):
"""Mount a partition."""
_check_native_mode()
# Soft-block if the mount target already contains user data that would
# be hidden by the new mount. The UI re-submits with force_shadowed=True
# to override.
if not request.force_shadowed:
shadowed = check_shadowed_data(request.mount_point)
if shadowed:
return {
"success": False,
"needs_force": "shadowed",
"shadowed_data": shadowed,
"error": (
f"{request.mount_point} contains {len(shadowed['entries'])} "
f"existing data "
f"{'entry' if len(shadowed['entries']) == 1 else 'entries'}. "
f"Mounting now would hide them on the underlying filesystem."
),
}
result = mount_drive(
device=request.device,
mount_point=request.mount_point,