Skip to content

Commit 2d02253

Browse files
authored
[DownloadBuildArtifactsV0] Replace decompress-zip with extract-zip package (#19569)
* [DownloadBuildArtifactsV0] Replace decompress-zip with extract-zip package * bump task version * wrap in promise
1 parent b535743 commit 2d02253

File tree

14 files changed

+208
-39
lines changed

14 files changed

+208
-39
lines changed

Tasks/DownloadBuildArtifactsV0/DownloadHandlers/DownloadHandlerContainerZip.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { FilesystemProvider, ZipProvider } from 'artifact-engine/Providers';
44
import * as tl from 'azure-pipelines-task-lib/task';
55
import * as path from 'path';
66
import * as DecompressZip from 'decompress-zip';
7+
#if NODE20
8+
import * as extract from 'extract-zip'
9+
#endif
710

811
/**
912
* Handler for download artifact via build API
@@ -39,9 +42,15 @@ export class DownloadHandlerContainerZip extends DownloadHandler {
3942
}
4043

4144
tl.debug(`Extracting ${this.zipLocation} to ${unzipLocation}`);
42-
45+
#if NODE20
46+
tl.debug(`Using extract-zip package for extracting archive`);
47+
extract(this.zipLocation, { dir: unzipLocation }).then(() => {
48+
resolve();
49+
}).catch((error) => {
50+
reject(error);
51+
});
52+
#else
4353
const unzipper = new DecompressZip(this.zipLocation);
44-
4554
unzipper.on('error', err => {
4655
return reject(tl.loc('ExtractionFailed', err));
4756
});
@@ -54,7 +63,7 @@ export class DownloadHandlerContainerZip extends DownloadHandler {
5463
unzipper.extract({
5564
path: unzipLocation
5665
});
57-
66+
#endif
5867
});
5968

6069
return unZipPromise;

Tasks/DownloadBuildArtifactsV0/_buildConfigs/Node20/package-lock.json

+85
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tasks/DownloadBuildArtifactsV0/_buildConfigs/Node20/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"artifact-engine": "^1.4.0",
2323
"azure-devops-node-api": "^10.2.2",
2424
"azure-pipelines-task-lib": "^4.4.0",
25-
"decompress-zip": "0.3.3"
25+
"decompress-zip": "0.3.3",
26+
"extract-zip": "2.0.1"
2627
},
2728
"devDependencies": {
2829
"typescript": "5.1.6"

Tasks/DownloadBuildArtifactsV0/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 235,
12+
"Minor": 236,
1313
"Patch": 0
1414
},
1515
"groups": [

Tasks/DownloadBuildArtifactsV0/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 235,
12+
"Minor": 236,
1313
"Patch": 0
1414
},
1515
"groups": [
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|0.235.0
2-
Node20_229_3|0.235.1
1+
Default|0.236.0
2+
Node20_229_3|0.236.1

_generated/DownloadBuildArtifactsV0/DownloadHandlers/DownloadHandlerContainerZip.ts

-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ export class DownloadHandlerContainerZip extends DownloadHandler {
3939
}
4040

4141
tl.debug(`Extracting ${this.zipLocation} to ${unzipLocation}`);
42-
4342
const unzipper = new DecompressZip(this.zipLocation);
44-
4543
unzipper.on('error', err => {
4644
return reject(tl.loc('ExtractionFailed', err));
4745
});
@@ -54,7 +52,6 @@ export class DownloadHandlerContainerZip extends DownloadHandler {
5452
unzipper.extract({
5553
path: unzipLocation
5654
});
57-
5855
});
5956

6057
return unZipPromise;

_generated/DownloadBuildArtifactsV0/task.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 235,
12+
"Minor": 236,
1313
"Patch": 0
1414
},
1515
"groups": [
@@ -321,7 +321,7 @@
321321
}
322322
],
323323
"_buildConfigMapping": {
324-
"Default": "0.235.0",
325-
"Node20_229_3": "0.235.1"
324+
"Default": "0.236.0",
325+
"Node20_229_3": "0.236.1"
326326
}
327327
}

_generated/DownloadBuildArtifactsV0/task.loc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 235,
12+
"Minor": 236,
1313
"Patch": 0
1414
},
1515
"groups": [
@@ -321,7 +321,7 @@
321321
}
322322
],
323323
"_buildConfigMapping": {
324-
"Default": "0.235.0",
325-
"Node20_229_3": "0.235.1"
324+
"Default": "0.236.0",
325+
"Node20_229_3": "0.236.1"
326326
}
327327
}

_generated/DownloadBuildArtifactsV0_Node20/DownloadHandlers/DownloadHandlerContainerZip.ts

+6-15
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { FilesystemProvider, ZipProvider } from 'artifact-engine/Providers';
44
import * as tl from 'azure-pipelines-task-lib/task';
55
import * as path from 'path';
66
import * as DecompressZip from 'decompress-zip';
7+
import * as extract from 'extract-zip'
78

89
/**
910
* Handler for download artifact via build API
@@ -39,22 +40,12 @@ export class DownloadHandlerContainerZip extends DownloadHandler {
3940
}
4041

4142
tl.debug(`Extracting ${this.zipLocation} to ${unzipLocation}`);
42-
43-
const unzipper = new DecompressZip(this.zipLocation);
44-
45-
unzipper.on('error', err => {
46-
return reject(tl.loc('ExtractionFailed', err));
47-
});
48-
49-
unzipper.on('extract', log => {
50-
tl.debug(`Extracted ${this.zipLocation} to ${unzipLocation} successfully`);
51-
return resolve();
52-
});
53-
54-
unzipper.extract({
55-
path: unzipLocation
43+
tl.debug(`Using extract-zip package for extracting archive`);
44+
extract(this.zipLocation, { dir: unzipLocation }).then(() => {
45+
resolve();
46+
}).catch((error) => {
47+
reject(error);
5648
});
57-
5849
});
5950

6051
return unZipPromise;

0 commit comments

Comments
 (0)