Skip to content

Commit

Permalink
Merge pull request #1200 from ivanduplenskikh/users/ivanduplenskikh/4…
Browse files Browse the repository at this point in the history
…16704362

Add zipStream destroy call when response is aborted
  • Loading branch information
tkasparek authored Oct 4, 2023
2 parents 6a88be6 + 030a885 commit 08725d7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Extensions/ArtifactEngine/Providers/webProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class WebProvider implements IArtifactProvider {
var downloadSize: number = 0;
var contentType: string = artifactItem.contentType;
var itemUrl: string = artifactItem.metadata['downloadUrl'];
var zipStream = null;
itemUrl = itemUrl.replace(/([^:]\/)\/+/g, "$1");
this.webClient.get(itemUrl, contentType ? { 'Accept': contentType } : undefined).then((res: HttpClientResponse) => {
res.message.on('data', (chunk) => {
Expand All @@ -59,12 +60,17 @@ export class WebProvider implements IArtifactProvider {
this.artifactItemStore.updateDownloadSize(artifactItem, downloadSize);
});
res.message.on('error', (error) => {
if (zipStream) {
zipStream.destroy(error);
Logger.logMessage(error);
}
reject(error);
});

if (res.message.headers['content-encoding'] === 'gzip') {
try {
resolve(res.message.pipe(zlib.createUnzip()));
zipStream = zlib.createUnzip();
resolve(res.message.pipe(zipStream));
}
catch (err) {
reject(err);
Expand Down
2 changes: 1 addition & 1 deletion Extensions/ArtifactEngine/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Extensions/ArtifactEngine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "artifact-engine",
"version": "1.2.0",
"version": "1.3.0",
"description": "Artifact Engine to download artifacts from jenkins, teamcity, vsts",
"repository": {
"type": "git",
Expand Down

0 comments on commit 08725d7

Please sign in to comment.