fix(release-upload): clear progress timer on upload completion/error and add periodic upload progress reporting
This commit is contained in:
@@ -47,6 +47,7 @@ async function uploadFile(filepath: string): Promise<void> {
|
|||||||
let data = '';
|
let data = '';
|
||||||
res.on('data', chunk => data += chunk);
|
res.on('data', chunk => data += chunk);
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
|
clearInterval(progressInterval);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
console.log(`✓ ${filename} uploaded successfully`);
|
console.log(`✓ ${filename} uploaded successfully`);
|
||||||
@@ -57,13 +58,30 @@ async function uploadFile(filepath: string): Promise<void> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
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
|
// Stream: write header, pipe file, write footer
|
||||||
req.write(header);
|
req.write(header);
|
||||||
const stream = fs.createReadStream(filepath);
|
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', () => {
|
stream.on('end', () => {
|
||||||
|
bytesWritten += footer.length;
|
||||||
req.write(footer);
|
req.write(footer);
|
||||||
req.end();
|
req.end();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# 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)
|
## 2026-01-09 - 0.4.0 - feat(displays)
|
||||||
add display detection and management (sway) with daemon APIs and UI controls
|
add display detection and management (sway) with daemon APIs and UI controls
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user