修复问题3
This commit is contained in:
@@ -461,6 +461,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
downloadSizeText.textContent = `${downloaded} / ${total} — 下载完成`;
|
downloadSizeText.textContent = `${downloaded} / ${total} — 下载完成`;
|
||||||
downloadProgressText.textContent = '100%';
|
downloadProgressText.textContent = '100%';
|
||||||
downloadProgressFill.style.width = '100%';
|
downloadProgressFill.style.width = '100%';
|
||||||
|
downloadSizeText.textContent = `${downloaded} / ${total} - download complete`;
|
||||||
|
if (transcodeDetailText) transcodeDetailText.textContent = 'Starting transcode...';
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
showTranscodePhase();
|
showTranscodePhase();
|
||||||
}, 600);
|
}, 600);
|
||||||
|
|||||||
10
server.js
10
server.js
@@ -392,6 +392,8 @@ const ensureSourceCached = async ({ s3Client, bucket, key, targetPath, onProgres
|
|||||||
const s3Stream = response.Body;
|
const s3Stream = response.Body;
|
||||||
const totalBytes = response.ContentLength || 0;
|
const totalBytes = response.ContentLength || 0;
|
||||||
let downloadedBytes = 0;
|
let downloadedBytes = 0;
|
||||||
|
let lastLoggedPercent = -1;
|
||||||
|
let lastLoggedBytes = 0;
|
||||||
|
|
||||||
logger.log(`[download] response received bucket=${bucket} key=${key} totalBytes=${totalBytes || 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);
|
const writeStream = fs.createWriteStream(targetPath);
|
||||||
s3Stream.on('data', (chunk) => {
|
s3Stream.on('data', (chunk) => {
|
||||||
downloadedBytes += chunk.length;
|
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') {
|
if (typeof onProgress === 'function') {
|
||||||
onProgress({ totalBytes, downloadedBytes, cacheExists: false });
|
onProgress({ totalBytes, downloadedBytes, cacheExists: false });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user