@nxtedition/lib 19.0.29 → 19.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/s3.js +9 -7
package/package.json
CHANGED
package/s3.js
CHANGED
|
@@ -127,10 +127,6 @@ export async function upload(
|
|
|
127
127
|
throw new Error(`Invalid ContentLength: ${ContentLength}`)
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
const dir = await fs.promises.mkdtemp(path.join(tmpdir, 's3-upload-'))
|
|
131
|
-
outerSignal?.throwIfAborted()
|
|
132
|
-
|
|
133
|
-
await fs.promises.stat(dir)
|
|
134
130
|
outerSignal?.throwIfAborted()
|
|
135
131
|
|
|
136
132
|
const queue = new PQueue({ concurrency: queueSize })
|
|
@@ -142,7 +138,11 @@ export async function upload(
|
|
|
142
138
|
outerSignal?.addEventListener('abort', abort)
|
|
143
139
|
|
|
144
140
|
let uploadId
|
|
141
|
+
let uploadDir
|
|
145
142
|
try {
|
|
143
|
+
uploadDir = await fs.promises.mkdtemp(path.join(tmpdir, 's3-upload-'))
|
|
144
|
+
signal.throwIfAborted()
|
|
145
|
+
|
|
146
146
|
const multipartUploadOutput = await s3.send(
|
|
147
147
|
new AWS.CreateMultipartUploadCommand({
|
|
148
148
|
Bucket,
|
|
@@ -155,14 +155,14 @@ export async function upload(
|
|
|
155
155
|
const uploader = {
|
|
156
156
|
size: 0,
|
|
157
157
|
hasher: crypto.createHash('md5'),
|
|
158
|
-
part: new PartUploader(
|
|
158
|
+
part: new PartUploader(uploadDir, 1, signal),
|
|
159
159
|
number: 1,
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
const maybeFlush = (minSize) => {
|
|
163
163
|
if (uploader.part.size && (minSize == null || uploader.part.size >= minSize)) {
|
|
164
164
|
const part = uploader.part
|
|
165
|
-
uploader.part = new PartUploader(
|
|
165
|
+
uploader.part = new PartUploader(uploadDir, ++uploader.number, signal)
|
|
166
166
|
|
|
167
167
|
const promise = queue.add(() => part.end(s3, { Bucket, Key, UploadId: uploadId }))
|
|
168
168
|
promises.push(promise)
|
|
@@ -253,6 +253,8 @@ export async function upload(
|
|
|
253
253
|
throw err
|
|
254
254
|
} finally {
|
|
255
255
|
outerSignal?.removeEventListener('abort', abort)
|
|
256
|
-
|
|
256
|
+
if (uploadDir) {
|
|
257
|
+
await fs.promises.rmdir(uploadDir, { recursive: true })
|
|
258
|
+
}
|
|
257
259
|
}
|
|
258
260
|
}
|