mirror of https://github.com/actions/toolkit
update loop for upload
parent
b1f55c6942
commit
18751738a8
|
@ -19,6 +19,7 @@
|
|||
"@octokit/request-error": "^5.0.0",
|
||||
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
|
||||
"archiver": "^5.3.1",
|
||||
"async": "^3.2.5",
|
||||
"crypto": "^1.0.1",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"twirp-ts": "^2.5.0",
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
"@octokit/request-error": "^5.0.0",
|
||||
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
|
||||
"archiver": "^5.3.1",
|
||||
"async": "^3.2.5",
|
||||
"crypto": "^1.0.1",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"twirp-ts": "^2.5.0",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as stream from 'stream'
|
||||
import * as async from 'async'
|
||||
import * as ZipStream from 'zip-stream'
|
||||
import * as core from '@actions/core'
|
||||
import {createReadStream} from 'fs'
|
||||
|
@ -39,30 +40,23 @@ export async function createZipUploadStream(
|
|||
|
||||
zip.on('finish', zipFinishCallback)
|
||||
zip.on('end', zipEndCallback)
|
||||
|
||||
// for (const file of uploadSpecification) {
|
||||
const fileUploadPromesses = uploadSpecification.map(async file => {
|
||||
return new Promise((resolve, reject) => {
|
||||
async.forEachOf(uploadSpecification, async file => {
|
||||
if (file.sourcePath !== null) {
|
||||
// Add a normal file to the zip
|
||||
zip.entry(
|
||||
createReadStream(file.sourcePath),
|
||||
{name: file.destinationPath},
|
||||
function (err, entry) {
|
||||
core.debug(`Entry is: ${entry}`)
|
||||
if (err) reject(err)
|
||||
else resolve(entry)
|
||||
if (err) throw err
|
||||
}
|
||||
)
|
||||
} else {
|
||||
zip.entry(null, {name: file.destinationPath}, function (err, entry) {
|
||||
core.debug(`Entry is: ${entry}`)
|
||||
if (err) reject(err)
|
||||
resolve(entry)
|
||||
if (err) throw err
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const bufferSize = getUploadChunkSize()
|
||||
const zipUploadStream = new ZipUploadStream(bufferSize)
|
||||
|
@ -72,9 +66,9 @@ export async function createZipUploadStream(
|
|||
core.debug(
|
||||
`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`
|
||||
)
|
||||
await Promise.all(fileUploadPromesses)
|
||||
zip.finalize()
|
||||
|
||||
// zip.pipe(zipUploadStream)
|
||||
zip.finalize()
|
||||
return zipUploadStream
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue