(path: Path)
| 3385 | path = Path(raw).expanduser() |
| 3386 | if not path.is_absolute(): |
| 3387 | path = PROJECT_ROOT / path |
| 3388 | return path |
| 3389 | |
| 3390 | |
| 3391 | def _effective_wiki_dir_for_user(user_id: str) -> Optional[Path]: |
| 3392 | root = _configured_wiki_root() |
| 3393 | if root is None: |
| 3394 | return None |
| 3395 | label = role_utils.storage_label_for_user_id(user_id, project_root=PROJECT_ROOT) |
| 3396 | if root.name == label: |
| 3397 | return root |
| 3398 | scoped = root / label |
| 3399 | return scoped if scoped.exists() else root |
| 3400 | |
| 3401 | |
| 3402 | def _wiki_node_file_exists(root: Path, relative_path: str) -> bool: |
| 3403 | if not relative_path: |
| 3404 | return False |
| 3405 | relative = Path(relative_path) |
| 3406 | if (root / relative).exists(): |
| 3407 | return True |
| 3408 | if root.name and relative.parts and relative.parts[0] == root.name: |
| 3409 | return (root / Path(*relative.parts[1:])).exists() |
| 3410 | return False |
| 3411 | |
| 3412 | |
| 3413 | def _filter_wiki_nodes_for_configured_dir(nodes: Iterable[Dict[str, Any]]) -> Optional[List[Dict[str, Any]]]: |
| 3414 | root = _configured_wiki_root() |
| 3415 | if root is None: |
| 3416 | return None |
| 3417 | filtered = [] |
| 3418 | for node in nodes or []: |
| 3419 | relative_path = str(node.get("file_path") or "").strip() |
| 3420 | if _wiki_node_file_exists(root, relative_path): |
| 3421 | filtered.append(node) |
| 3422 | return filtered |
| 3423 |
no test coverage detected