Silence optional ComfyUI asset ingest failures

This commit is contained in:
magicwang1111
2026-04-28 14:05:49 +08:00
parent 065d737601
commit 7c4d9c43ff
2 changed files with 29 additions and 4 deletions
+4 -4
View File
@@ -704,8 +704,8 @@ def _register_output_asset(file_path):
try:
ingest_existing_file(file_path)
except Exception as e:
print(f"[PreviewVideo] Failed to register output asset: {e}")
except Exception:
return
def _build_local_media_view_url(filename, subfolder, folder_type):
@@ -1565,8 +1565,8 @@ class PreviewVideo:
handle.write(_fetch_image(video_url))
try:
_register_output_asset(file_path)
except Exception as e:
print(f"[PreviewVideo] Failed to register output asset: {e}")
except Exception:
pass
return {
"ui": {
+25
View File
@@ -195,6 +195,31 @@ class BackendConfigTests(unittest.TestCase):
):
kling_nodes._register_output_asset("example.mp4")
def test_preview_video_silences_broken_asset_ingest_function(self):
fake_app_module = ModuleType("app")
fake_assets_module = ModuleType("app.assets")
fake_services_module = ModuleType("app.assets.services")
fake_ingest_module = ModuleType("app.assets.services.ingest")
def broken_ingest(_file_path):
raise TypeError("'NoneType' object is not callable")
fake_ingest_module.ingest_existing_file = broken_ingest
with mock.patch.dict(
sys.modules,
{
"app": fake_app_module,
"app.assets": fake_assets_module,
"app.assets.services": fake_services_module,
"app.assets.services.ingest": fake_ingest_module,
},
):
with mock.patch("builtins.print") as print_mock:
kling_nodes._register_output_asset("example.mp4")
print_mock.assert_not_called()
def test_preview_video_keeps_result_when_asset_registration_fails(self):
with tempfile.TemporaryDirectory() as tmpdir:
tmpdir_path = Path(tmpdir)