From bfef6f651dc88568766b92e0cc09c85ca0c7b440 Mon Sep 17 00:00:00 2001 From: CN-JS-HuiBai Date: Fri, 3 Apr 2026 23:27:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=983?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/main.js | 2 ++ server.js | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/public/js/main.js b/public/js/main.js index aee13f7..7a69de7 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -461,6 +461,8 @@ document.addEventListener('DOMContentLoaded', () => { downloadSizeText.textContent = `${downloaded} / ${total} — 下载完成`; downloadProgressText.textContent = '100%'; downloadProgressFill.style.width = '100%'; + downloadSizeText.textContent = `${downloaded} / ${total} - download complete`; + if (transcodeDetailText) transcodeDetailText.textContent = 'Starting transcode...'; setTimeout(() => { showTranscodePhase(); }, 600); diff --git a/server.js b/server.js index b31fccd..d979d6f 100644 --- a/server.js +++ b/server.js @@ -392,6 +392,8 @@ const ensureSourceCached = async ({ s3Client, bucket, key, targetPath, onProgres const s3Stream = response.Body; const totalBytes = response.ContentLength || 0; let downloadedBytes = 0; + let lastLoggedPercent = -1; + let lastLoggedBytes = 0; logger.log(`[download] response received bucket=${bucket} key=${key} totalBytes=${totalBytes || 0}`); @@ -403,6 +405,14 @@ const ensureSourceCached = async ({ s3Client, bucket, key, targetPath, onProgres const writeStream = fs.createWriteStream(targetPath); s3Stream.on('data', (chunk) => { downloadedBytes += chunk.length; + const percent = totalBytes ? Math.min(100, Math.round((downloadedBytes / totalBytes) * 100)) : 0; + const shouldLogPercent = totalBytes && percent >= lastLoggedPercent + 5; + const shouldLogBytes = !totalBytes && downloadedBytes >= lastLoggedBytes + (5 * 1024 * 1024); + if (shouldLogPercent || shouldLogBytes) { + logger.log(`[download] progress bucket=${bucket} key=${key} downloadedBytes=${downloadedBytes} totalBytes=${totalBytes || 0} percent=${percent}`); + lastLoggedPercent = percent; + lastLoggedBytes = downloadedBytes; + } if (typeof onProgress === 'function') { onProgress({ totalBytes, downloadedBytes, cacheExists: false }); }