Handle UNC binary directories in AI structure flow
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-22 00:54:43 +03:00
parent de8b0eb795
commit 51d52ccf04
3 changed files with 134 additions and 34 deletions
+17 -3
View File
@@ -4,6 +4,7 @@ import asyncio
import base64
import hashlib
import json
import ntpath
import os
import re
import shutil
@@ -581,9 +582,15 @@ def _agent_id_for_source(settings: "ProjectSettingsRequest", source: "ImportSour
return str(agent.get("agent_id") or "").strip()
async def _start_ai_structure_agent_job(*, project_id: str, effective_project_id: str, input_path: Path) -> AgentImportJob:
async def _start_ai_structure_agent_job(
*,
project_id: str,
effective_project_id: str,
input_path: str,
detected_binary_relative_path: str | None = None,
) -> AgentImportJob:
settings = _project_settings_or_404(project_id)
binary_files = _ai_structure_binary_files(input_path)
binary_files = _ai_structure_binary_files(input_path, detected_binary_relative_path=detected_binary_relative_path)
if not binary_files:
raise HTTPException(status_code=400, detail="Во входном пути не найдены файлы .cf или .cfe.")
@@ -641,7 +648,14 @@ async def _start_ai_structure_agent_job(*, project_id: str, effective_project_id
)
def _ai_structure_binary_files(input_path: Path) -> list[Path]:
def _ai_structure_binary_files(raw_input_path: str, detected_binary_relative_path: str | None = None) -> list[Path]:
lowered = raw_input_path.strip().casefold()
if lowered.endswith(".cf") or lowered.endswith(".cfe"):
return [Path(raw_input_path)]
if detected_binary_relative_path:
windows_path = ntpath.join(raw_input_path, detected_binary_relative_path.replace("/", "\\"))
return [Path(windows_path)]
input_path = Path(raw_input_path)
if input_path.is_file() and input_path.suffix.casefold() in {".cf", ".cfe"}:
return [input_path]
if not input_path.exists() or not input_path.is_dir():