refactor(855-F B9-5): 프로젝트 옛 사본 꼴 읽기 걷음 — 옛 항목 폴더 옮겨 받기 · 옛 복사본 채우기
- M02_Item_Snapshot: migrate_items · items_dir · OLD_ITEMS_DIRNAME · complete_old 지움 · 맞춤 답 「옮겨받음」 칸 뺌 - M02_Item_Copy: _migrated 대신 structures_dir · 읽을 때 complete_old 안 부름 - 까닭: 프로젝트 사본 0 · templates/items 0(보충 3-1 · 판단 거리 3 = 걷음) · 옛 꼴 호환 안 만듦(요구 898 · 899) - 시험: test_item_copy_complete 옛 꼴 둘(옛 복사본 채움 · 옛 항목 폴더 옮겨 받음) 지움 — 죽은 길만 붙듦 · test_structures_summary_snapshot 맞춤 답 칸 하나 고침 - 검증: 관련 시험 270 — 통과 267 · 실패 3 = test_719_2 셋(고치기 전부터 같은 실패 · 묶음 3 몫) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
복사본 = `{프로젝트}/templates/structures/{구조물 id}/`
|
||||
(`M02_Item_Snapshot`) · 길의 폴더 = 구조물 id.
|
||||
파일마다 판 = 내용 해시 — 쓸 때 판이 다르면 `Stale`(409). 고치면 manifest 에 `고침` 을 남겨 지울 때
|
||||
`_지난/` 에 옮겨 둠. 옛 복사본(새 파일 없음) · 옛 항목 폴더는 읽을 때 채우고 옮겨 받음.
|
||||
`_지난/` 에 옮겨 둠.
|
||||
계산은 복사본만 씀(마스터 현재값 안 읽음) — 원본 항목이 바뀌거나 지워져도 그대로.
|
||||
"""
|
||||
|
||||
@@ -29,10 +29,7 @@ from M02_MasterTemplete.M02_Item_Snapshot import (
|
||||
PICKS_FILE,
|
||||
VALUES_FILE,
|
||||
build_snapshot,
|
||||
complete_old,
|
||||
folder_name,
|
||||
items_dir,
|
||||
migrate_items,
|
||||
now_text,
|
||||
retire,
|
||||
same_item,
|
||||
@@ -68,21 +65,13 @@ class Stale(ValueError):
|
||||
self.current = current
|
||||
|
||||
|
||||
def _migrated(project_root: str | Path) -> Path:
|
||||
"""구조물 복사본 뿌리 — 옛 항목 폴더가 남았으면 먼저 옮겨 받음."""
|
||||
if items_dir(project_root).is_dir():
|
||||
migrate_items(project_root)
|
||||
return structures_dir(project_root)
|
||||
|
||||
|
||||
def folder_of(project_root: str | Path, folder: str) -> Path:
|
||||
"""구조물 복사본 폴더 — 이름 모양이 틀리거나 없으면 LookupError(404)."""
|
||||
if not FOLDER_PATTERN.match(folder):
|
||||
raise LookupError(f"복사본 폴더 이름 모양이 아님 「{folder}」")
|
||||
target = _migrated(project_root) / folder
|
||||
target = structures_dir(project_root) / folder
|
||||
if not (target / MANIFEST_NAME).is_file():
|
||||
raise LookupError(f"복사본이 없음 「{folder}」")
|
||||
complete_old(target)
|
||||
return target
|
||||
|
||||
|
||||
@@ -97,7 +86,7 @@ def source_changed(manifest: dict[str, Any]) -> bool | None:
|
||||
|
||||
def list_items(project_root: str | Path, only: str | None = None) -> list[dict[str, Any]]:
|
||||
"""복사본 목록 — `only` = 그 폴더 하나만(고르기 모달 · 원본 대조를 그 하나만 · 156-2)."""
|
||||
base = _migrated(project_root)
|
||||
base = structures_dir(project_root)
|
||||
out = []
|
||||
for child in sorted(base.iterdir()) if base.is_dir() else []:
|
||||
if not child.is_dir() or not FOLDER_PATTERN.match(child.name):
|
||||
@@ -106,7 +95,6 @@ def list_items(project_root: str | Path, only: str | None = None) -> list[dict[s
|
||||
continue
|
||||
if not (child / MANIFEST_NAME).is_file():
|
||||
continue
|
||||
complete_old(child)
|
||||
manifest = read_json(child / MANIFEST_NAME) or {}
|
||||
origin = manifest.get("원본") or {}
|
||||
changed = source_changed(manifest)
|
||||
@@ -289,7 +277,7 @@ def prefetch(project_root: str | Path, owner_id: str, item: dict[str, Any]) -> d
|
||||
folder = folder_name(owner_id)
|
||||
if not FOLDER_PATTERN.match(folder):
|
||||
raise ValueError(f"구조물 id 모양이 아님 「{owner_id}」")
|
||||
target = _migrated(project_root) / folder
|
||||
target = structures_dir(project_root) / folder
|
||||
manifest = read_json(target / MANIFEST_NAME)
|
||||
made = not (isinstance(manifest, dict) and same_item(manifest, item))
|
||||
if made:
|
||||
|
||||
Reference in New Issue
Block a user