Skip to content

Commit bb1053a

Browse files
authored
@actions/artifact 0.3.1 update (#420)
* Updates to 0.3.1 package update
1 parent a28977e commit bb1053a

9 files changed

Lines changed: 81 additions & 93 deletions

File tree

packages/artifact/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ You can use this package to interact with the actions artifacts.
77
- [Download a Single Artifact](#Download-a-Single-Artifact)
88
- [Download All Artifacts](#Download-all-Artifacts)
99
- [Additional Documentation](#Additional-Documentation)
10+
- [Contributions](#Contributions)
1011

1112
Relative paths and absolute paths are both allowed. Relative paths are rooted against the current working directory.
1213

packages/artifact/RELEASES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@
1919
- Exponential backoff when retryable status codes are encountered
2020
- Clearer error message if storage quota has been reached
2121
- Improved logging and output during artifact download
22+
23+
### 0.3.1
24+
25+
- Fix to ensure temporary gzip files get correctly deleted during artifact upload
26+
- Remove spaces as a forbidden character during upload

packages/artifact/__tests__/util.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ describe('Utils', () => {
5757
'my|artifact',
5858
'my*artifact',
5959
'my?artifact',
60-
'my artifact',
6160
''
6261
]
6362
for (const invalidName of invalidNames) {
@@ -87,7 +86,6 @@ describe('Utils', () => {
8786
'some/invalid|artifact/path',
8887
'some/invalid*artifact/path',
8988
'some/invalid?artifact/path',
90-
'some/invalid artifact/path',
9189
''
9290
]
9391
for (const invalidName of invalidNames) {

packages/artifact/docs/additional-information.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ When uploading an artifact, the inputted `name` parameter along with the files s
1717
- |
1818
- \*
1919
- ?
20-
- empty space
2120

2221
In addition to the aforementioned characters, the inputted `name` also cannot include the following
2322
- \

packages/artifact/docs/implementation-details.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Warning: Implementation details may change at any time without notice. This is m
44

55
## Upload/Compression flow
66

7-
![image](https://user-images.githubusercontent.com/16109154/77190819-38685d80-6ada-11ea-8281-4703ff8cc025.png)
7+
![image](https://user-images.githubusercontent.com/16109154/79765587-19522b00-8327-11ea-9679-410bb10e1b13.png)
88

99
## Retry Logic when downloading an individual file
1010

packages/artifact/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/artifact/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@actions/artifact",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"preview": true,
55
"description": "Actions artifact lib",
66
"keywords": [

packages/artifact/src/internal/upload-http-client.ts

Lines changed: 71 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -248,91 +248,85 @@ export class UploadHttpClient {
248248
}
249249
} else {
250250
// the file that is being uploaded is greater than 64k in size, a temporary file gets created on disk using the
251-
// npm tmp-promise package and this file gets used during compression for the GZip file that gets created
252-
return tmp
253-
.file()
254-
.then(async tmpFile => {
255-
// create a GZip file of the original file being uploaded, the original file should not be modified in any way
256-
uploadFileSize = await createGZipFileOnDisk(
251+
// npm tmp-promise package and this file gets used to create a GZipped file
252+
const tempFile = await tmp.file()
253+
254+
// create a GZip file of the original file being uploaded, the original file should not be modified in any way
255+
uploadFileSize = await createGZipFileOnDisk(
256+
parameters.file,
257+
tempFile.path
258+
)
259+
260+
let uploadFilePath = tempFile.path
261+
262+
// compression did not help with size reduction, use the original file for upload and delete the temp GZip file
263+
if (totalFileSize < uploadFileSize) {
264+
uploadFileSize = totalFileSize
265+
uploadFilePath = parameters.file
266+
isGzip = false
267+
}
268+
269+
let abortFileUpload = false
270+
// upload only a single chunk at a time
271+
while (offset < uploadFileSize) {
272+
const chunkSize = Math.min(
273+
uploadFileSize - offset,
274+
parameters.maxChunkSize
275+
)
276+
277+
// if an individual file is greater than 100MB (1024*1024*100) in size, display extra information about the upload status
278+
if (uploadFileSize > 104857600) {
279+
this.statusReporter.updateLargeFileStatus(
257280
parameters.file,
258-
tmpFile.path
281+
offset,
282+
uploadFileSize
259283
)
260-
let uploadFilePath = tmpFile.path
261-
262-
// compression did not help with size reduction, use the original file for upload and delete the temp GZip file
263-
if (totalFileSize < uploadFileSize) {
264-
uploadFileSize = totalFileSize
265-
uploadFilePath = parameters.file
266-
isGzip = false
267-
tmpFile.cleanup()
268-
}
284+
}
269285

270-
let abortFileUpload = false
271-
// upload only a single chunk at a time
272-
while (offset < uploadFileSize) {
273-
const chunkSize = Math.min(
274-
uploadFileSize - offset,
275-
parameters.maxChunkSize
276-
)
286+
const start = offset
287+
const end = offset + chunkSize - 1
288+
offset += parameters.maxChunkSize
277289

278-
// if an individual file is greater than 100MB (1024*1024*100) in size, display extra information about the upload status
279-
if (uploadFileSize > 104857600) {
280-
this.statusReporter.updateLargeFileStatus(
281-
parameters.file,
282-
offset,
283-
uploadFileSize
284-
)
285-
}
290+
if (abortFileUpload) {
291+
// if we don't want to continue in the event of an error, any pending upload chunks will be marked as failed
292+
failedChunkSizes += chunkSize
293+
continue
294+
}
286295

287-
const start = offset
288-
const end = offset + chunkSize - 1
289-
offset += parameters.maxChunkSize
296+
const result = await this.uploadChunk(
297+
httpClientIndex,
298+
parameters.resourceUrl,
299+
fs.createReadStream(uploadFilePath, {
300+
start,
301+
end,
302+
autoClose: false
303+
}),
304+
start,
305+
end,
306+
uploadFileSize,
307+
isGzip,
308+
totalFileSize
309+
)
290310

291-
if (abortFileUpload) {
292-
// if we don't want to continue in the event of an error, any pending upload chunks will be marked as failed
293-
failedChunkSizes += chunkSize
294-
continue
295-
}
311+
if (!result) {
312+
// Chunk failed to upload, report as failed and do not continue uploading any more chunks for the file. It is possible that part of a chunk was
313+
// successfully uploaded so the server may report a different size for what was uploaded
314+
isUploadSuccessful = false
315+
failedChunkSizes += chunkSize
316+
core.warning(`Aborting upload for ${parameters.file} due to failure`)
317+
abortFileUpload = true
318+
}
319+
}
296320

297-
const result = await this.uploadChunk(
298-
httpClientIndex,
299-
parameters.resourceUrl,
300-
fs.createReadStream(uploadFilePath, {
301-
start,
302-
end,
303-
autoClose: false
304-
}),
305-
start,
306-
end,
307-
uploadFileSize,
308-
isGzip,
309-
totalFileSize
310-
)
321+
// Delete the temporary file that was created as part of the upload. If the temp file does not get manually deleted by
322+
// calling cleanup, it gets removed when the node process exits. For more info see: https://www.npmjs.com/package/tmp-promise#about
323+
await tempFile.cleanup()
311324

312-
if (!result) {
313-
// Chunk failed to upload, report as failed and do not continue uploading any more chunks for the file. It is possible that part of a chunk was
314-
// successfully uploaded so the server may report a different size for what was uploaded
315-
isUploadSuccessful = false
316-
failedChunkSizes += chunkSize
317-
core.warning(
318-
`Aborting upload for ${parameters.file} due to failure`
319-
)
320-
abortFileUpload = true
321-
}
322-
}
323-
})
324-
.then(
325-
async (): Promise<UploadFileResult> => {
326-
// only after the file upload is complete and the temporary file is deleted, return the UploadResult
327-
return new Promise(resolve => {
328-
resolve({
329-
isSuccess: isUploadSuccessful,
330-
successfulUploadSize: uploadFileSize - failedChunkSizes,
331-
totalSize: totalFileSize
332-
})
333-
})
334-
}
335-
)
325+
return {
326+
isSuccess: isUploadSuccessful,
327+
successfulUploadSize: uploadFileSize - failedChunkSizes,
328+
totalSize: totalFileSize
329+
}
336330
}
337331
}
338332

packages/artifact/src/internal/utils.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,7 @@ Header Information: ${JSON.stringify(response.message.headers, undefined, 2)}
245245
*
246246
* FilePaths can include characters such as \ and / which are not permitted in the artifact name alone
247247
*/
248-
const invalidArtifactFilePathCharacters = [
249-
'"',
250-
':',
251-
'<',
252-
'>',
253-
'|',
254-
'*',
255-
'?',
256-
' '
257-
]
248+
const invalidArtifactFilePathCharacters = ['"', ':', '<', '>', '|', '*', '?']
258249
const invalidArtifactNameCharacters = [
259250
...invalidArtifactFilePathCharacters,
260251
'\\',

0 commit comments

Comments
 (0)