From aec0fdcd315336a6bef62fca1acd1845d096140f Mon Sep 17 00:00:00 2001 From: gahusb Date: Mon, 11 May 2026 02:54:25 +0900 Subject: [PATCH] =?UTF-8?q?fix(packs-lab):=20tier=20=EB=94=94=EB=A0=89?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EC=A0=9C=EA=B1=B0(=ED=8F=89=EB=A9=B4=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0)=20+=20deployer=20SERVICES=EC=97=90=20packs-?= =?UTF-8?q?lab=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제 1: deploy-nas.sh의 SERVICES 화이트리스트에 packs-lab이 빠져 있어 NAS 운영 디렉토리에 소스 sync가 안 됐고 docker compose가 packs-lab을 빌드 못해 컨테이너가 안 떠 있었다. 문제 2: routes.py가 PACK_BASE_DIR/{tier}/{filename} 트리 구조로 저장 → 사용자 요청에 따라 평면 구조(PACK_BASE_DIR/{filename})로 변경. tier 구분은 filename 규칙(prefix 등)으로 admin이 관리. - scripts/deploy-nas.sh: SERVICES에 packs-lab 추가 (10개 → 11개) - routes.py: tier 디렉토리 제거 (target = PACK_BASE_DIR / filename, host_path = PACK_HOST_DIR / filename) - tests: tier 분기 사용처 평면 구조로 보정 (size_mismatch / host_path_check) - 25/25 passing Co-Authored-By: Claude Opus 4.7 (1M context) --- packs-lab/app/routes.py | 8 ++++---- packs-lab/tests/test_routes.py | 6 +++--- scripts/deploy-nas.sh | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packs-lab/app/routes.py b/packs-lab/app/routes.py index 03c5669..0090620 100644 --- a/packs-lab/app/routes.py +++ b/packs-lab/app/routes.py @@ -129,9 +129,9 @@ async def upload( filename = _check_filename(payload["filename"]) expected_size = int(payload["size_bytes"]) - tier_dir = PACK_BASE_DIR / tier - tier_dir.mkdir(parents=True, exist_ok=True) - target = tier_dir / filename + # tier 디렉토리는 만들지 않고 PACK_BASE_DIR 평면 구조에 저장. tier 구분은 filename 규칙으로. + PACK_BASE_DIR.mkdir(parents=True, exist_ok=True) + target = PACK_BASE_DIR / filename if target.exists(): raise HTTPException(status_code=409, detail="이미 존재하는 파일명입니다. 다른 이름으로 업로드하거나 기존 파일을 먼저 삭제하세요") @@ -155,7 +155,7 @@ async def upload( # Supabase·DSM에 노출되는 file_path는 NAS 호스트 절대경로여야 한다. # 컨테이너 경로(target)는 마운트된 호스트경로의 다른 시점일 뿐이라, 같은 디렉토리 구조를 보유. - host_path = PACK_HOST_DIR / tier / filename + host_path = PACK_HOST_DIR / filename # supabase INSERT sb = _supabase() diff --git a/packs-lab/tests/test_routes.py b/packs-lab/tests/test_routes.py index 02ed84b..21084a5 100644 --- a/packs-lab/tests/test_routes.py +++ b/packs-lab/tests/test_routes.py @@ -160,8 +160,8 @@ def test_upload_size_mismatch(tmp_path, monkeypatch): ) assert resp.status_code == 400 assert "크기" in resp.json()["detail"] - # 파일이 정리되었는지 확인 - assert not (tmp_path / "pro" / "size_mismatch_test.zip").exists() + # 파일이 정리되었는지 확인 (평면 구조) + assert not (tmp_path / "size_mismatch_test.zip").exists() def test_upload_jti_replay(tmp_path, monkeypatch): @@ -292,7 +292,7 @@ def test_upload_stores_host_path_not_container_path(tmp_path, monkeypatch): assert resp.status_code == 200 # Supabase에 저장된 file_path는 호스트 경로 - expected_host = str(host_base / "pro" / "host_path_check.zip") + expected_host = str(host_base / "host_path_check.zip") assert captured_insert["file_path"] == expected_host # 응답의 file_path도 호스트 경로 assert resp.json()["file_path"] == expected_host diff --git a/scripts/deploy-nas.sh b/scripts/deploy-nas.sh index 12321b4..a37180e 100644 --- a/scripts/deploy-nas.sh +++ b/scripts/deploy-nas.sh @@ -2,7 +2,7 @@ set -euo pipefail # ── 서비스 목록 (한 곳에서만 관리) ── -SERVICES="lotto travel-proxy deployer stock-lab music-lab blog-lab realestate-lab agent-office personal nginx scripts" +SERVICES="lotto travel-proxy deployer stock-lab music-lab blog-lab realestate-lab agent-office personal packs-lab nginx scripts" # 1. 자동 감지: Docker 컨테이너 내부인가? if [ -d "/repo" ] && [ -d "/runtime" ]; then