mirror of https://github.com/actions/toolkit
adding check for running
parent
18751738a8
commit
bef1fc5f67
|
@ -7,6 +7,7 @@ import {UploadZipSpecification} from './upload-zip-specification'
|
||||||
import {getUploadChunkSize} from '../shared/config'
|
import {getUploadChunkSize} from '../shared/config'
|
||||||
|
|
||||||
export const DEFAULT_COMPRESSION_LEVEL = 6
|
export const DEFAULT_COMPRESSION_LEVEL = 6
|
||||||
|
export var isRunning = false
|
||||||
|
|
||||||
// Custom stream transformer so we can set the highWaterMark property
|
// Custom stream transformer so we can set the highWaterMark property
|
||||||
// See https://github.com/nodejs/node/issues/8855
|
// See https://github.com/nodejs/node/issues/8855
|
||||||
|
@ -27,6 +28,10 @@ export async function createZipUploadStream(
|
||||||
uploadSpecification: UploadZipSpecification[],
|
uploadSpecification: UploadZipSpecification[],
|
||||||
compressionLevel: number = DEFAULT_COMPRESSION_LEVEL
|
compressionLevel: number = DEFAULT_COMPRESSION_LEVEL
|
||||||
): Promise<ZipUploadStream> {
|
): Promise<ZipUploadStream> {
|
||||||
|
if (isRunning) {
|
||||||
|
throw new Error('The function is already running')
|
||||||
|
}
|
||||||
|
isRunning = true
|
||||||
core.debug(
|
core.debug(
|
||||||
`Creating Artifact archive with compressionLevel: ${compressionLevel}`
|
`Creating Artifact archive with compressionLevel: ${compressionLevel}`
|
||||||
)
|
)
|
||||||
|
@ -40,23 +45,27 @@ 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 => {
|
try {
|
||||||
if (file.sourcePath !== null) {
|
await async.forEachOf(uploadSpecification, async file => {
|
||||||
zip.entry(
|
if (file.sourcePath !== null) {
|
||||||
createReadStream(file.sourcePath),
|
zip.entry(
|
||||||
{name: file.destinationPath},
|
createReadStream(file.sourcePath),
|
||||||
function (err, entry) {
|
{name: file.destinationPath},
|
||||||
|
function (err, entry) {
|
||||||
|
core.debug(`Entry is: ${entry}`)
|
||||||
|
if (err) throw err
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
zip.entry(null, {name: file.destinationPath}, function (err, entry) {
|
||||||
core.debug(`Entry is: ${entry}`)
|
core.debug(`Entry is: ${entry}`)
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
}
|
})
|
||||||
)
|
}
|
||||||
} else {
|
})
|
||||||
zip.entry(null, {name: file.destinationPath}, function (err, entry) {
|
} finally {
|
||||||
core.debug(`Entry is: ${entry}`)
|
isRunning = false
|
||||||
if (err) throw err
|
}
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const bufferSize = getUploadChunkSize()
|
const bufferSize = getUploadChunkSize()
|
||||||
const zipUploadStream = new ZipUploadStream(bufferSize)
|
const zipUploadStream = new ZipUploadStream(bufferSize)
|
||||||
|
|
Loading…
Reference in New Issue