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",
|
"@octokit/request-error": "^5.0.0",
|
||||||
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
|
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
|
||||||
"archiver": "^5.3.1",
|
"archiver": "^5.3.1",
|
||||||
|
"async": "^3.2.5",
|
||||||
"crypto": "^1.0.1",
|
"crypto": "^1.0.1",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"twirp-ts": "^2.5.0",
|
"twirp-ts": "^2.5.0",
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
"@octokit/request-error": "^5.0.0",
|
"@octokit/request-error": "^5.0.0",
|
||||||
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
|
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
|
||||||
"archiver": "^5.3.1",
|
"archiver": "^5.3.1",
|
||||||
|
"async": "^3.2.5",
|
||||||
"crypto": "^1.0.1",
|
"crypto": "^1.0.1",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"twirp-ts": "^2.5.0",
|
"twirp-ts": "^2.5.0",
|
||||||
|
@ -64,4 +65,4 @@
|
||||||
"typedoc-plugin-markdown": "^3.17.1",
|
"typedoc-plugin-markdown": "^3.17.1",
|
||||||
"typescript": "^5.2.2"
|
"typescript": "^5.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as stream from 'stream'
|
import * as stream from 'stream'
|
||||||
|
import * as async from 'async'
|
||||||
import * as ZipStream from 'zip-stream'
|
import * as ZipStream from 'zip-stream'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {createReadStream} from 'fs'
|
import {createReadStream} from 'fs'
|
||||||
|
@ -39,29 +40,22 @@ export async function createZipUploadStream(
|
||||||
|
|
||||||
zip.on('finish', zipFinishCallback)
|
zip.on('finish', zipFinishCallback)
|
||||||
zip.on('end', zipEndCallback)
|
zip.on('end', zipEndCallback)
|
||||||
|
async.forEachOf(uploadSpecification, async file => {
|
||||||
// for (const file of uploadSpecification) {
|
if (file.sourcePath !== null) {
|
||||||
const fileUploadPromesses = uploadSpecification.map(async file => {
|
zip.entry(
|
||||||
return new Promise((resolve, reject) => {
|
createReadStream(file.sourcePath),
|
||||||
if (file.sourcePath !== null) {
|
{name: file.destinationPath},
|
||||||
// Add a normal file to the zip
|
function (err, entry) {
|
||||||
zip.entry(
|
|
||||||
createReadStream(file.sourcePath),
|
|
||||||
{name: file.destinationPath},
|
|
||||||
function (err, entry) {
|
|
||||||
core.debug(`Entry is: ${entry}`)
|
|
||||||
if (err) reject(err)
|
|
||||||
else resolve(entry)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
zip.entry(null, {name: file.destinationPath}, function (err, entry) {
|
|
||||||
core.debug(`Entry is: ${entry}`)
|
core.debug(`Entry is: ${entry}`)
|
||||||
if (err) reject(err)
|
if (err) throw err
|
||||||
resolve(entry)
|
}
|
||||||
})
|
)
|
||||||
}
|
} else {
|
||||||
})
|
zip.entry(null, {name: file.destinationPath}, function (err, entry) {
|
||||||
|
core.debug(`Entry is: ${entry}`)
|
||||||
|
if (err) throw err
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const bufferSize = getUploadChunkSize()
|
const bufferSize = getUploadChunkSize()
|
||||||
|
@ -72,9 +66,9 @@ export async function createZipUploadStream(
|
||||||
core.debug(
|
core.debug(
|
||||||
`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`
|
`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`
|
||||||
)
|
)
|
||||||
await Promise.all(fileUploadPromesses)
|
|
||||||
zip.finalize()
|
|
||||||
|
|
||||||
|
// zip.pipe(zipUploadStream)
|
||||||
|
zip.finalize()
|
||||||
return zipUploadStream
|
return zipUploadStream
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue