Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio video gallery: clear() reads and unlinks sidecars in the folder it locked (#15766)
Daniel Hana627f97d6830
diff --git a/studio/backend/core/inference/video_gallery.py b/studio/backend/core/inference/video_gallery.pyindex e1bd00b8381..fb01de253f9 100644--- a/studio/backend/core/inference/video_gallery.py+++ b/studio/backend/core/inference/video_gallery.py@@ -826,7 +826,7 @@ def clear(include_archived: bool = False, *, return_ids: bool = False) -> int |return [] if return_ids else 0cleared: list[str] = []for path in paths:- if _read_meta(_sidecar_path(path.stem)) is None:+ if _read_meta(_sidecar_path(path.stem, directory)) is None:continueif not include_archived and gallery_flags.is_archived(flags, path.stem):continue@@ -837,7 +837,7 @@ def clear(include_archived: bool = False, *, return_ids: bool = False) -> int |removed += 1cleared.append(path.stem)try:- _sidecar_path(path.stem).unlink()+ _sidecar_path(path.stem, directory).unlink()except OSError:pass# Once every owned clip is gone nothing is left to protect, so replace an unreadable store now or every later default clear still refuses.diff --git a/studio/backend/tests/test_video_gallery.py b/studio/backend/tests/test_video_gallery.pyindex 52aa0fee034..d94f34473c4 100644--- a/studio/backend/tests/test_video_gallery.py+++ b/studio/backend/tests/test_video_gallery.py@@ -175,6 +175,30 @@ def test_clear_returns_count():assert list(gallery.gallery_dir().glob("*.json")) == []+def test_clear_uses_the_locked_folder_when_the_folder_moves_mid_clear(monkeypatch, tmp_path):+ # A Settings relocation can change gallery_dir() while clear() holds the old folder's lock.+ record = gallery.save(_mp4(), _meta(prompt = "old folder"))+ old = gallery.gallery_dir()+ new = tmp_path / "relocated"+ new.mkdir()+ (new / f"{record['id']}.json").write_text(+ json.dumps(_meta(prompt = "new folder")), encoding = "utf-8"+ )+ (new / f"{record['id']}.mp4").write_bytes(_mp4())+ calls = []++ def _moving_dir():+ calls.append(1)+ return old if len(calls) == 1 else new++ monkeypatch.setattr(gallery, "gallery_dir", _moving_dir)+ assert gallery.clear(include_archived = True, return_ids = True) == [record["id"]]+ assert not (old / f"{record['id']}.mp4").exists()+ assert not (old / f"{record['id']}.json").exists()+ assert (new / f"{record['id']}.json").exists()+ assert (new / f"{record['id']}.mp4").exists()++def test_clear_preserves_orphan_mp4():foreign = gallery.gallery_dir() / "recording.mp4"foreign.write_bytes(_mp4())