fix(B03): 파일 수 초과 오탐 - 고른 파일 수 대신 최종 점유 슬롯 수로 판정

This commit is contained in:
2026-08-08 14:17:48 +09:00
parent 2ff37a6e41
commit c5d4b3f046
+13 -4
View File
@@ -268,10 +268,19 @@ export async function renderB03FileInput(root: HTMLElement): Promise<void> {
function onFileSelected(files: readonly File[], targetSlot?: FileSlot): void {
if (files.length === 0) return;
// 이미 고른 슬롯을 다시 고르는 것은 "교체"라 총 개수가 늘지 않는다 — 그 슬롯을 빼고 센다.
// (빼지 않으면 5개를 다 고른 뒤 하나만 바꾸려 할 때 개수 초과로 막힌다.)
const occupied = selectedStates().filter((state) => state.slot !== targetSlot).length;
if (occupied + files.length > UPLOAD_MAX_FILES) {
// 개수는 "고른 파일 수"가 아니라 **최종적으로 차는 슬롯 수**로 센다.
// 같은 슬롯을르는 것은 교체라 개수가 늘지 않는다 — 더하기로 세면 5개를 고른
// 뒤 파일 선택 영역으로 하나만 바꾸려 해도 초과로 막힌다(2026-08-08).
const occupied = new Set(selectedStates().map((state) => state.slot));
for (const file of files) {
const extension = getExtension(file.name);
const slot =
targetSlot ??
Array.from(slots.values()).find((candidate) => candidate.extensions.includes(extension))
?.slot;
if (slot) occupied.add(slot);
}
if (occupied.size > UPLOAD_MAX_FILES) {
pageError.textContent = L("B03_File_Error_Count");
return;
}