mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-02 21:06:52 +03:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e912d0852b |
@@ -35,7 +35,11 @@ from frigate.config.camera.updater import (
|
|||||||
)
|
)
|
||||||
from frigate.config.env import substitute_frigate_vars
|
from frigate.config.env import substitute_frigate_vars
|
||||||
from frigate.models import User
|
from frigate.models import User
|
||||||
from frigate.util.builtin import clean_camera_user_pass, get_record_segment_time
|
from frigate.util.builtin import (
|
||||||
|
clean_camera_user_pass,
|
||||||
|
clear_orphaned_comments,
|
||||||
|
get_record_segment_time,
|
||||||
|
)
|
||||||
from frigate.util.camera_cleanup import cleanup_camera_db, cleanup_camera_files
|
from frigate.util.camera_cleanup import cleanup_camera_db, cleanup_camera_files
|
||||||
from frigate.util.config import find_config_file
|
from frigate.util.config import find_config_file
|
||||||
from frigate.util.image import run_ffmpeg_snapshot
|
from frigate.util.image import run_ffmpeg_snapshot
|
||||||
@@ -1201,6 +1205,7 @@ async def delete_camera(
|
|||||||
# Remove camera from config
|
# Remove camera from config
|
||||||
if "cameras" in data and camera_name in data["cameras"]:
|
if "cameras" in data and camera_name in data["cameras"]:
|
||||||
del data["cameras"][camera_name]
|
del data["cameras"][camera_name]
|
||||||
|
clear_orphaned_comments(data["cameras"], data, "cameras")
|
||||||
|
|
||||||
# Remove camera from auth roles
|
# Remove camera from auth roles
|
||||||
auth = data.get("auth", {})
|
auth = data.get("auth", {})
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import unittest
|
|||||||
|
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
|
|
||||||
from frigate.util.builtin import update_yaml_file_bulk
|
from frigate.util.builtin import clear_orphaned_comments, update_yaml_file_bulk
|
||||||
|
|
||||||
|
|
||||||
class TestUpdateYaml(unittest.TestCase):
|
class TestUpdateYaml(unittest.TestCase):
|
||||||
@@ -178,6 +178,27 @@ class TestUpdateYaml(unittest.TestCase):
|
|||||||
assert data["cameras"]["cam1"]["detect"]["fps"] == 5
|
assert data["cameras"]["cam1"]["detect"]["fps"] == 5
|
||||||
assert "# tuned for the pi" in self._read()
|
assert "# tuned for the pi" in self._read()
|
||||||
|
|
||||||
|
def test_delete_only_camera_with_comment_on_cameras_key(self):
|
||||||
|
"""Deleting the only camera stays parseable when the cameras key
|
||||||
|
carries the default config's trailing comment."""
|
||||||
|
self._write(
|
||||||
|
"cameras: # No cameras defined, UI wizard should be used\n"
|
||||||
|
" cam1:\n"
|
||||||
|
" enabled: true\n"
|
||||||
|
"version: 0.18-0\n"
|
||||||
|
)
|
||||||
|
yaml = YAML()
|
||||||
|
with open(self.config_path) as f:
|
||||||
|
data = yaml.load(f)
|
||||||
|
del data["cameras"]["cam1"]
|
||||||
|
clear_orphaned_comments(data["cameras"], data, "cameras")
|
||||||
|
with open(self.config_path, "w") as f:
|
||||||
|
yaml.dump(data, f)
|
||||||
|
|
||||||
|
data = self._load()
|
||||||
|
assert data["cameras"] == {}
|
||||||
|
assert data["version"] == "0.18-0"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main(verbosity=2)
|
unittest.main(verbosity=2)
|
||||||
|
|||||||
Reference in New Issue
Block a user