Skip to content

fix(config): do not fail on a local disk that is not mounted - #3449

Merged
MichaIng merged 1 commit into
motioneye-project:devfrom
JamBalaya56562:fix/local-disk-not-mounted
Oct 12, 2026
Merged

MichaIng merged 1 commit into
motioneye-project:devfrom
JamBalaya56562:fix/local-disk-not-mounted

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

motion_camera_ui_to_dict() no longer raises a KeyError when a camera's local-disk-… storage device is not mounted: it logs an error and keeps the stored target dir.

Why

The partition was looked up with mounted_partitions[target_dev], so applying settings while the disk was not mounted failed with HTTP 500. Two ways to get there:

  • the disk goes away after the settings were opened (the UI then posts root_directory relative to the mount point, e.g. /Camera1);
  • posting back what GET /config/N/get/ returned for a camera whose disk is not mounted (motion_camera_dict_to_ui() then returns the whole target dir).

The stored target dir is kept rather than derived from root_directory, because a relative root directory cannot be resolved without the mount point; using it as is would silently move recordings to e.g. /Camera1 on the root filesystem.

Testing

  • New tests/test_local_disk.py: mounted round trip, unmounted round trip, and disk unmounted between opening and applying the settings. All 3 pass; with the previous config.py the unmounted cases fail with KeyError: '/dev/sda1' at config.py:1242.

  • Full suite in a Linux container (python:3.12-bookworm): 227 passed, 168 subtests passed.

  • End-to-end in Docker with a real partition (a loop device formatted ext4, mounted at /media/usb and listed by fdisk -l), driven with Playwright: store the disk as storage device with root directory /Camera1, reopen the settings, umount /media/usb, change the camera name and apply. The UI posted storage_device: local-disk-dev-loop1p1 with root_directory: /Camera1.

    this PR dev (6476d00)
    /config/0/set/ 200 500 {"error": "internal server error"}
    target_dir afterwards /media/usb/Camera1 /media/usb/Camera1 (nothing saved)
    new camera name saved not saved
  • ruff check / ruff format --check pass.

Separate from #3448, which touches the same function for a null storage device.

🤖 Generated with Claude Code

motion_camera_ui_to_dict() looked the partition of a local-disk storage
device up with mounted_partitions[target_dev], so applying settings while
the disk was not mounted raised a KeyError and failed with HTTP 500. This
happens when the disk goes away after the settings were opened, and when
posting back what GET returned for a camera whose disk is not mounted.

Keep the stored target dir in that case. The root directory cannot be
resolved without the mount point: the UI sends it relative to the mount
point when the disk was mounted at load time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JamBalaya56562
JamBalaya56562 force-pushed the fix/local-disk-not-mounted branch from 32bfb94 to fe1c687 Compare October 12, 2026 11:34

@MichaIng MichaIng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

@MichaIng MichaIng added this to the v0.45.0 milestone Oct 12, 2026
@MichaIng
MichaIng merged commit 7c8fc56 into motioneye-project:dev Oct 12, 2026
20 checks passed
@JamBalaya56562
JamBalaya56562 deleted the fix/local-disk-not-mounted branch October 12, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants