fix(854-2): M01 수식 문서 쓰기 안전 길 — 잠금 · 임시 파일 → 교체 · 문서별 판 대조 409 — 묶음 ①
- Doc.put 한 곳으로 씀(save · drop · Machine._register_docs) · Doc._LOCK 안 · 임시 파일 → os.replace - 판 = 문서 한 장 저장 글 지문 · 읽기가 「판」 을 줌 · /logic/doc/save 가 받은 판과 다르면 409(화면 Save_Stale 과 같은 글) · 판 없음 = 대조 안 함(옛 부름 · 시험) - M01 줄 쌓기 [저장]이 판을 보냄(M02 사본 길은 그대로) — 기계 목록 등록이 바꾼 문서를 옛 화면이 덮지 않음 - 수식 문서 폴더가 AISLO_MASTER_DIR 사본을 따름(마스터 사본 · 문서 정본이 갈리던 것) · 마스터만 사본인 시험은 정본 문서를 안 씀 - 시험 test_854_2_m01_doc_write — 옛 판 409 · 동시 두 저장 = 하나 ok 하나 409 · 기계 등록 뒤 옛 판 409 · 정본 안 씀 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -182,22 +182,26 @@ def register(batch: list[dict]) -> Callable[[], None]:
|
||||
|
||||
|
||||
def _register_docs(add: dict[str, list[str]], drop: set[str]) -> None:
|
||||
"""수식 문서의 「기계」 고르기 목록에 로직 목록과 같은 더함 · 뺌 — 바뀐 파일만 다시 씀."""
|
||||
"""수식 문서의 「기계」 고르기 목록에 로직 목록과 같은 더함 · 뺌 — 바뀐 파일만 다시 씀
|
||||
(수식 문서 쓰기 길 `Doc.put` · 잠금 안 — 화면 저장과 겹쳐도 한쪽이 덮지 않음)."""
|
||||
import master_doc_link as ml # noqa: E402
|
||||
|
||||
for path in sorted(ml.FOLDER.glob("수식_*.json")):
|
||||
data, hit = ml.load_file(path), False
|
||||
for doc in data.get("줄") or []:
|
||||
for v in doc.get("변수") or []:
|
||||
link = v.get("연결") or {}
|
||||
if link.get("갈래") != "선택" or v.get("이름") != "기계":
|
||||
continue
|
||||
codes = [c for c in link.get("목록") or [] if str(c) not in drop]
|
||||
codes += [c for c in add.get(str(doc.get("키")), []) if c not in codes]
|
||||
if codes != link.get("목록"):
|
||||
link["목록"], hit = codes, True
|
||||
if hit:
|
||||
path.write_text(ml.dump(data), encoding="utf-8", newline="\n")
|
||||
from M01_MasterData import M01_MasterData_Doc as docs
|
||||
|
||||
with docs._LOCK:
|
||||
for path in sorted(docs.folder().glob("수식_*.json")):
|
||||
data, hit = ml.load_file(path), False
|
||||
for doc in data.get("줄") or []:
|
||||
for v in doc.get("변수") or []:
|
||||
link = v.get("연결") or {}
|
||||
if link.get("갈래") != "선택" or v.get("이름") != "기계":
|
||||
continue
|
||||
codes = [c for c in link.get("목록") or [] if str(c) not in drop]
|
||||
codes += [c for c in add.get(str(doc.get("키")), []) if c not in codes]
|
||||
if codes != link.get("목록"):
|
||||
link["목록"], hit = codes, True
|
||||
if hit:
|
||||
docs.put(path, data)
|
||||
|
||||
|
||||
# ── 쓰는 곳 = `M01_MasterData_Machine_Uses`(수식 문서 기준 · 848-5) ──────────────
|
||||
|
||||
Reference in New Issue
Block a user