Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(onboarding): 优先报告本机目录错误

longmeidao02f701ced0eb
diff --git a/src/peach/routes_pages.py b/src/peach/routes_pages.py
index 66258b27e..223d8b3c8 100644
--- a/src/peach/routes_pages.py
+++ b/src/peach/routes_pages.py
@@ -781,7 +781,7 @@ def _setup_media_source_errors(dirs: Sequence[str], kinds: object,
source_kinds = list(kinds) if isinstance(kinds, (list, tuple)) else []
for index, path in enumerate(dirs):
kind = source_kinds[index] if index < len(source_kinds) else "local"
- if errors[index] or kind != "local":
+ if kind != "local":
continue
try:
validate(path)
diff --git a/tests/test_configuration_sources.py b/tests/test_configuration_sources.py
index c65405c39..8dc86c579 100644
--- a/tests/test_configuration_sources.py
+++ b/tests/test_configuration_sources.py
@@ -85,6 +85,18 @@ class MediaConfigurationTests(unittest.TestCase):
self.assertIn('name="media_root"', html)
self.assertIn('value="B:/"', html)
+ def test_setup_local_source_reports_native_directory_error_first(self):
+ from peach.routes_pages import _setup_media_source_errors
+
+ def missing_directory(_path):
+ raise ValueError("目录不存在:/missing")
+
+ errors = _setup_media_source_errors(
+ ["/missing"], ["local"],
+ ["Windows 中的对应路径必须包含盘符,例如 B:\\"], missing_directory,
+ )
+ self.assertEqual(errors, ["目录不存在:/missing"])
+
def test_completion_page_keeps_runtime_details_collapsed(self):
from peach.routes_pages import setup_done_page
with tempfile.TemporaryDirectory() as directory: