扫描QGIS模板
This commit is contained in:
@@ -172,6 +172,8 @@ def map_template_to_container(host_path: str) -> str:
|
||||
|
||||
主机: F:/project/xian/xian_algorithm_new/app/data/template/rainfall/xxx.qgz
|
||||
容器: /data/template/rainfall/xxx.qgz
|
||||
|
||||
已为容器路径时直接返回(幂等)。
|
||||
"""
|
||||
try:
|
||||
from config import settings
|
||||
@@ -179,16 +181,21 @@ def map_template_to_container(host_path: str) -> str:
|
||||
except Exception:
|
||||
container_tpl = ""
|
||||
|
||||
# 已经是容器路径,直接返回
|
||||
normalized = host_path.replace("\\", "/")
|
||||
if container_tpl and normalized.startswith(container_tpl.rstrip("/") + "/"):
|
||||
return normalized
|
||||
|
||||
if not container_tpl:
|
||||
# fallback: 用通用映射(走 9P,慢)
|
||||
return map_host_to_container(host_path)
|
||||
|
||||
normalized = host_path.replace("\\", "/").lower()
|
||||
# 找 "app/data/template/" 后面的部分
|
||||
marker = "app/data/template/"
|
||||
idx = normalized.find(marker)
|
||||
normalized_lower = normalized.lower()
|
||||
# 找模板子目录后面的相对路径(主机端 marker 从配置读取)
|
||||
marker = getattr(settings, "QGIS_HOST_TEMPLATE_SUBDIR", "app/data/template").rstrip("/") + "/"
|
||||
idx = normalized_lower.find(marker.lower())
|
||||
if idx >= 0:
|
||||
relative = host_path.replace("\\", "/")[idx + len(marker):]
|
||||
relative = normalized[idx + len(marker):]
|
||||
return f"{container_tpl.rstrip('/')}/{relative}"
|
||||
|
||||
return map_host_to_container(host_path)
|
||||
|
||||
Reference in New Issue
Block a user