- 공용 `common_util_time.ts`(날짜 · 시각 · 오늘/어제/n 일 전 · Z 없는 옛 글 = UTC) · `common_util_time.py`(UTC Z 글 · 한국 시각) - 화면 바꿈: 대시보드(프로젝트 · 휴지통 · 시스템 로그 · 보관함 · 홈 카드) · B09 굳힘 · E03 · E05 · E07 · M02 호표 이력 · 목록 고친 날 · 지난 판 - 서버: 응답 datetime = UTC + Z(main.py) · 로컬 시각 저장 → UTC · 대시보드 경과일 = UTC 기준 · 엑셀 날짜 · 파일 이름 = 한국 시각 - 시험: test_593_time(서울 · 뉴욕 · Z 없는 옛 글 · 서버 글) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
"""임시 보관함 라우터 보조 — 조각 수 계산·묶음 폴더 확인·상태 갱신.
|
|
|
|
라우터가 700줄을 넘어 떼어냈다(2026-09-04). 본체와 청크 모듈이 함께 쓰는 것만 둔다.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
from B03_FileInput.B03_FileInput_Repository_Temp import (
|
|
get_temp_batch,
|
|
get_temp_batch_file_types,
|
|
is_batch_required_complete,
|
|
mark_temp_batch_completed,
|
|
mark_temp_batch_incomplete,
|
|
)
|
|
from common_util.common_util_storage import (
|
|
resolve_temp_batch_path,
|
|
)
|
|
from common_util.common_util_time import utc_text
|
|
|
|
_POINT_CLOUD_FILE_TYPES = frozenset({"las", "laz"})
|
|
|
|
|
|
def _total_chunks(size_bytes: int, chunk_size_bytes: int) -> int:
|
|
return max(1, (size_bytes + chunk_size_bytes - 1) // chunk_size_bytes)
|
|
|
|
|
|
def _iso(value: Any) -> str | None:
|
|
return utc_text(value) if isinstance(value, datetime) else None
|
|
|
|
|
|
async def _batch_root(connection: Any, *, batch_id: str, user_id: int) -> Path:
|
|
"""소유권을 확인하고 묶음 폴더를 돌려준다."""
|
|
await get_temp_batch(connection, batch_id=batch_id, user_id=user_id)
|
|
return Path(resolve_temp_batch_path(user_id, batch_id))
|
|
|
|
|
|
async def _refresh_batch_status(connection: Any, *, batch_id: str) -> bool:
|
|
"""필수 파일 충족 여부에 맞춰 상태를 맞춘다. 완료 여부를 돌려준다."""
|
|
file_types = await get_temp_batch_file_types(connection, batch_id=batch_id)
|
|
complete = is_batch_required_complete(file_types)
|
|
if complete:
|
|
await mark_temp_batch_completed(connection, batch_id=batch_id)
|
|
else:
|
|
# 파일을 지워 필수 조건이 깨진 경우 — 프로젝트 연결 대상에서 빠져야 한다.
|
|
await mark_temp_batch_incomplete(connection, batch_id=batch_id)
|
|
return complete
|