fix(packs-lab): tier 디렉토리 제거(평면 구조) + deployer SERVICES에 packs-lab 추가
문제 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) <noreply@anthropic.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user