feat(765-6): 초기값 사본에서 배수 공유 캐시 뺌 · 복원은 노선 몫만 갈음(캐시 제자리) · 복제가 설계 벌 묶음 안 지표면 id 고침
- common_util_initial_snapshot: 배수 사본 = 노선 몫만(하강장 · 도엽 좌표 · 강우 뺌 · 약 105 → 20 MB) · 복원은 폴더 통째 지우지 않음 · 캐시 든 옛 사본의 캐시 칸은 건너뜀 - common_util_project_copy._fix_files(통째 복제 · --replace 같은 길): design_sets/<지형>/ 의 db.json · 그 벌 초기값 · B06 표본 설정 · meta.json 지표면 id → 새 id · 노선 id 는 꺼낼 때 늘 새로 받아 안 고침 · 코리도 안 건드림 - 시험 test_765_design_sets 에 둘 덧 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -169,6 +169,49 @@ def _copy_tree(source: Path, target: Path) -> None:
|
||||
shutil.copytree(source, target)
|
||||
|
||||
|
||||
_DRAINAGE_TREE = "B04_PreProcess/drainage"
|
||||
|
||||
|
||||
def _drainage_shared(name: str) -> bool:
|
||||
return name.startswith(DRAINAGE_SHARED_PREFIXES)
|
||||
|
||||
|
||||
def _save_drainage(source: Path, target: Path) -> None:
|
||||
"""배수 폴더 중 노선 몫만 뜸 — 공유 캐시(하강장 · 도엽 좌표 · 강우)는 뺌(765-6 ·
|
||||
약 105 → 20 MB)."""
|
||||
if not source.is_dir():
|
||||
return
|
||||
if target.exists():
|
||||
shutil.rmtree(target)
|
||||
top = str(source)
|
||||
shutil.copytree(
|
||||
source,
|
||||
target,
|
||||
ignore=lambda folder, names: [n for n in names if folder == top and _drainage_shared(n)],
|
||||
)
|
||||
|
||||
|
||||
def _restore_drainage(stored: Path, live: Path) -> None:
|
||||
"""노선 몫만 갈음 — 공유 캐시는 제자리에 둠(지우면 다음 배수 계산이 처음부터 · 765-6) ·
|
||||
캐시 든 옛 사본도 캐시 칸은 건너뜀."""
|
||||
if live.is_dir():
|
||||
for path in live.iterdir():
|
||||
if _drainage_shared(path.name):
|
||||
continue
|
||||
if path.is_dir():
|
||||
shutil.rmtree(path)
|
||||
else:
|
||||
path.unlink()
|
||||
live.mkdir(parents=True, exist_ok=True)
|
||||
for path in stored.iterdir():
|
||||
if _drainage_shared(path.name):
|
||||
continue
|
||||
if path.is_dir():
|
||||
shutil.copytree(path, live / path.name)
|
||||
else:
|
||||
shutil.copy2(path, live / path.name)
|
||||
|
||||
|
||||
async def _dump_rows(
|
||||
connection: aiomysql.Connection, table: str, route_id: int
|
||||
) -> list[dict[str, Any]]:
|
||||
@@ -211,7 +254,8 @@ async def save_initial_snapshot(
|
||||
_write_design_route_csv(target / DESIGN_ROUTE_CSV_NAME, design_route_points)
|
||||
|
||||
for tree in _FILE_TREES:
|
||||
_copy_tree(root / tree, target / tree.replace("/", "__"))
|
||||
save = _save_drainage if tree == _DRAINAGE_TREE else _copy_tree
|
||||
save(root / tree, target / tree.replace("/", "__"))
|
||||
|
||||
# 코리도는 체인이 마지막에 만든다 — 있으면 함께 뜬다(없으면 브라우저 폴백 그대로).
|
||||
from B05_Profile.B05_Profile_Router_Corridor import corridor_path
|
||||
@@ -294,6 +338,9 @@ def restore_snapshot_files(project_root: Path, route_id: int | None = None) -> N
|
||||
else: # 배수 폴더 없는 스냅샷 — 관 편집은 비움(초기값에 없던 것)
|
||||
shutil.rmtree(edits, ignore_errors=True)
|
||||
continue
|
||||
if tree == _DRAINAGE_TREE:
|
||||
_restore_drainage(stored, root / tree)
|
||||
continue
|
||||
_copy_tree(stored, root / tree)
|
||||
|
||||
# 코리도는 복원으로 만든 **새 route id** 이름으로 되돌린다 — 이름이 어긋나면 브라우저가
|
||||
|
||||
Reference in New Issue
Block a user