fix: capture real S3 ETag from PUT response headers instead of placeholder
This commit is contained in:
parent
5ffbad3c65
commit
fc43dffed1
1 changed files with 2 additions and 25 deletions
|
|
@ -232,7 +232,7 @@ class TransferEngine {
|
|||
|
||||
const t0 = Date.now();
|
||||
|
||||
await this._putRequest(url, buf);
|
||||
const etag = await this._putRequest(url, buf); // real ETag from S3
|
||||
|
||||
const elapsed = (Date.now() - t0) / 1000;
|
||||
const bps = length / Math.max(elapsed, 0.001);
|
||||
|
|
@ -249,7 +249,7 @@ class TransferEngine {
|
|||
job.eta = job.speedBps > 0 ? Math.round(remaining / job.speedBps) : null;
|
||||
|
||||
this.onProgress(this._publicJob(job));
|
||||
return `"part-${partNumber}-etag-placeholder"`; // real ETag comes from S3 response headers
|
||||
return etag;
|
||||
}
|
||||
|
||||
_putRequest(url, body) {
|
||||
|
|
@ -283,29 +283,6 @@ class TransferEngine {
|
|||
});
|
||||
}
|
||||
|
||||
// Fix _uploadPart to capture real ETag from PUT response
|
||||
async _uploadPartWithEtag(fd, offset, length, url, partNumber, job) {
|
||||
const buf = Buffer.allocUnsafe(length);
|
||||
fs.readSync(fd, buf, 0, length, offset);
|
||||
|
||||
const t0 = Date.now();
|
||||
const etag = await this._putRequest(url, buf);
|
||||
const elapsed = (Date.now() - t0) / 1000;
|
||||
const bps = length / Math.max(elapsed, 0.001);
|
||||
|
||||
job._speedSamples.push(bps);
|
||||
if (job._speedSamples.length > 5) job._speedSamples.shift();
|
||||
job.speedBps = job._speedSamples.reduce((a, b) => a + b, 0) / job._speedSamples.length;
|
||||
|
||||
job.uploadedBytes += length;
|
||||
job.percent = Math.round((job.uploadedBytes / job.size) * 100);
|
||||
const remaining = job.size - job.uploadedBytes;
|
||||
job.eta = job.speedBps > 0 ? Math.round(remaining / job.speedBps) : null;
|
||||
|
||||
this.onProgress(this._publicJob(job));
|
||||
return etag;
|
||||
}
|
||||
|
||||
_publicJob(job) {
|
||||
return {
|
||||
id: job.id,
|
||||
|
|
|
|||
Loading…
Reference in a new issue