From 9a19b107085c8c5f4c2f0b282ab9beff805ac05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Thu, 25 Jun 2026 10:36:23 +0400 Subject: [PATCH] =?UTF-8?q?v1.0.178:=20fix=20zipIdx=20=E2=86=92=20zipEntry?= =?UTF-8?q?=20(=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B0=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82).=20ZIP=20temp=20entry=20?= =?UTF-8?q?=D0=B4=D0=B5=D1=80=D0=B6=D0=B8=D1=82=D1=81=D1=8F=20=D0=B4=D0=BE?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BD=D1=86=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/files.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/deploy/files.js b/deploy/files.js index 0410baa..cb5f2a9 100644 --- a/deploy/files.js +++ b/deploy/files.js @@ -305,10 +305,10 @@ function applyParseResult(entry, parsed, elapsed) { async function addZipFile(file) { var zipEntry = { name: file.name, lastModified: file.lastModified, size: file.size, status: { kind: 'unzipping' } }; state.files.push(zipEntry); - var zipIdx = state.files.length - 1; render(state); try { + // Шаг 1: распаковать ZIP на бэкенде var zipResp = await new Promise(function(resolve, reject) { var xhr = new XMLHttpRequest(); xhr.open('POST', UNZIP_URL); @@ -323,16 +323,17 @@ async function addZipFile(file) { }); if (!zipResp.ok || !zipResp.files) throw new Error('unzip failed'); - // Убрать временную строку ZIP - state.files.splice(zipIdx, 1); - render(state); - - // Каждый файл из архива — через addRegularFile (единый путь) - for (var zi = 0; zi < zipResp.files.length; zi++) { + // Шаг 2: обработать каждый файл из архива + // Временная строка ZIP остаётся в таблице — обновляем её статус + var total = zipResp.files.length; + for (var zi = 0; zi < total; zi++) { var zf = zipResp.files[zi]; + zipEntry.status = { kind: 'unzipping' }; // обновляем статус + render(state); + if (zf.error) continue; - // base64 → Blob → File + // base64 → File → addRegularFile (единый путь) var byteStr = atob(zf.data_b64); var bytes = new Uint8Array(byteStr.length); for (var b = 0; b < byteStr.length; b++) bytes[b] = byteStr.charCodeAt(b); @@ -341,8 +342,15 @@ async function addZipFile(file) { await addRegularFile(extractedFile); } + + // Шаг 3: убрать временную строку ZIP (только после успешной обработки всех файлов) + var zipPos = state.files.indexOf(zipEntry); + if (zipPos >= 0) state.files.splice(zipPos, 1); + render(state); + } catch(ze) { - state.files[zipIdx].status = { kind: 'error', text: 'ZIP: ' + ze.message }; + // Ошибка — показать на строке ZIP (zipEntry всё ещё в state.files) + zipEntry.status = { kind: 'error', text: 'ZIP: ' + ze.message }; render(state); } }