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 }); }