diff --git a/.gitea/release-upload.ts b/.gitea/release-upload.ts index a8f6bfe..e662216 100644 --- a/.gitea/release-upload.ts +++ b/.gitea/release-upload.ts @@ -47,6 +47,7 @@ async function uploadFile(filepath: string): Promise { let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => { + clearInterval(progressInterval); console.log(data); if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) { console.log(`✓ ${filename} uploaded successfully`); @@ -57,13 +58,30 @@ async function uploadFile(filepath: string): Promise { }); }); - req.on('error', reject); + req.on('error', (err) => { + clearInterval(progressInterval); + reject(err); + }); + + // Track upload progress + let bytesWritten = header.length; + const progressInterval = setInterval(() => { + const percent = Math.round((bytesWritten / contentLength) * 100); + console.log(` ${filename}: ${percent}% (${Math.round(bytesWritten / 1024 / 1024)}MB / ${Math.round(contentLength / 1024 / 1024)}MB)`); + }, 10000); // Stream: write header, pipe file, write footer req.write(header); const stream = fs.createReadStream(filepath); - stream.on('error', reject); + stream.on('data', (chunk) => { + bytesWritten += chunk.length; + }); + stream.on('error', (err) => { + clearInterval(progressInterval); + reject(err); + }); stream.on('end', () => { + bytesWritten += footer.length; req.write(footer); req.end(); }); diff --git a/changelog.md b/changelog.md index 746c0ba..1ad23c6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Changelog +## 2026-01-09 - 0.4.1 - fix(release-upload) +clear progress timer on upload completion/error and add periodic upload progress reporting + +- Clear the progress interval on response end and on stream/error to avoid leaking timers. +- Track bytesWritten (header + stream chunks + footer) to compute accurate progress percentages. +- Log upload progress (percent and MB) every 10 seconds for visibility. +- Handle stream errors by clearing the progress timer and rejecting with the error. + ## 2026-01-09 - 0.4.0 - feat(displays) add display detection and management (sway) with daemon APIs and UI controls