mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-25 14:57:07 +03:00
remove a deleted camera's recordings from disk
Camera delete removed RECORD_DIR/<camera> and CLIPS_DIR/<camera>, but recordings live under RECORD_DIR/<date>/<hour>/<camera>, so the camera's segments stayed on disk after their rows were deleted and nothing reclaimed them. Neither path holds per-camera data, so they only matched when a camera name collided with something else, like a classification model's dataset, the thumbs or faces folders, or a date-named recordings folder. Delete now removes the <camera> and <camera>@sub folders under each recordings hour, plus the camera's thumbs, previews, lpr, and triggers folders.
This commit is contained in:
@@ -264,3 +264,41 @@ class TestCameraFileCleanup(unittest.TestCase):
|
||||
]
|
||||
|
||||
self.assertEqual(remaining, other)
|
||||
|
||||
def test_delete_removes_recordings_and_keeps_colliding_dirs(self):
|
||||
own = [
|
||||
"recordings/2026-11-22/10/front/00.00.mp4",
|
||||
"recordings/2026-11-22/10/front@sub/00.00.mp4",
|
||||
"recordings/2026-11-23/03/front/10.00.mp4",
|
||||
"clips/thumbs/front/a.webp",
|
||||
"clips/previews/front/1.mp4",
|
||||
"clips/lpr/front/a/1.jpg",
|
||||
"clips/triggers/front/t.webp",
|
||||
]
|
||||
other = [
|
||||
"recordings/2026-11-22/10/front_door/00.00.mp4",
|
||||
"recordings/front/keep.mp4",
|
||||
"clips/front/dataset/a.jpg",
|
||||
"clips/thumbs/front_door/b.webp",
|
||||
]
|
||||
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
for name in own + other:
|
||||
path = os.path.join(root, name)
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
open(path, "w").close()
|
||||
|
||||
clips = os.path.join(root, "clips")
|
||||
with patch.multiple(
|
||||
camera_cleanup,
|
||||
CLIPS_DIR=clips,
|
||||
RECORD_DIR=os.path.join(root, "recordings"),
|
||||
THUMB_DIR=os.path.join(clips, "thumbs"),
|
||||
):
|
||||
camera_cleanup.cleanup_camera_files("front")
|
||||
|
||||
remaining = [
|
||||
n for n in own + other if os.path.exists(os.path.join(root, n))
|
||||
]
|
||||
|
||||
self.assertEqual(remaining, other)
|
||||
|
||||
Reference in New Issue
Block a user