Skip to content

Commit df72cac

Browse files
author
Mikhail Arkhipov
authored
Replace unzip package (#1419)
* Undo changes * Test fixes * Increase timeout * Remove double event listening * Remove test * Revert "Remove test" This reverts commit e240c3f. * Revert "Remove double event listening" This reverts commit af573be. * #1096 The if statement is automatically formatted incorrectly * Merge fix * Add more tests * More tests * Typo * Test * Also better handle multiline arguments * Add a couple missing periods [skip ci] * Undo changes * Test fixes * Increase timeout * Remove double event listening * Remove test * Revert "Remove test" This reverts commit e240c3f. * Revert "Remove double event listening" This reverts commit af573be. * Merge fix * #1257 On type formatting errors for args and kwargs * Handle f-strings * Stop importing from test code * #1308 Single line statements leading to an indentation on the next line * #726 editing python after inline if statement invalid indent * Undo change * Move constant * Harden LS startup error checks * #1364 Intellisense doesn't work after specific const string * Telemetry for the analysis enging * PR feedback * Fix typo * Test baseline update * Jedi 0.12 * Priority to goto_defition * News * Replace unzip
1 parent 39612b4 commit df72cac

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,7 @@
18481848
"md5": "2.2.1",
18491849
"minimatch": "3.0.4",
18501850
"named-js-regexp": "1.3.3",
1851+
"node-stream-zip": "^1.6.0",
18511852
"opn": "5.3.0",
18521853
"pidusage": "1.2.0",
18531854
"reflect-metadata": "0.1.12",
@@ -1862,7 +1863,6 @@
18621863
"uint64be": "1.0.1",
18631864
"unicode": "10.0.0",
18641865
"untildify": "3.0.2",
1865-
"unzip": "0.1.11",
18661866
"vscode-debugadapter": "1.28.0",
18671867
"vscode-debugprotocol": "1.28.0",
18681868
"vscode-extension-telemetry": "0.0.15",

src/client/activation/downloader.ts

+33-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as fs from 'fs';
55
import * as path from 'path';
66
import * as request from 'request';
77
import * as requestProgress from 'request-progress';
8-
import * as unzip from 'unzip';
98
import { ExtensionContext, OutputChannel, ProgressLocation, window } from 'vscode';
109
import { STANDARD_OUTPUT_CHANNEL } from '../common/constants';
1110
import { noop } from '../common/core.utils';
@@ -16,6 +15,9 @@ import { IServiceContainer } from '../ioc/types';
1615
import { HashVerifier } from './hashVerifier';
1716
import { PlatformData } from './platformData';
1817

18+
// tslint:disable-next-line:no-require-imports no-var-requires
19+
const StreamZip = require('node-stream-zip');
20+
1921
const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-analysis';
2022
const downloadBaseFileName = 'python-analysis-vscode';
2123
const downloadVersion = '0.1.0';
@@ -109,15 +111,37 @@ export class AnalysisEngineDownloader {
109111
const installFolder = path.join(extensionPath, this.engineFolder);
110112
const deferred = createDeferred();
111113

112-
fs.createReadStream(tempFilePath)
113-
.pipe(unzip.Extract({ path: installFolder }))
114-
.on('finish', () => {
115-
deferred.resolve();
116-
})
117-
.on('error', (err) => {
118-
deferred.reject(err);
114+
const title = 'Extracting files... ';
115+
await window.withProgress({
116+
location: ProgressLocation.Window,
117+
title
118+
}, (progress) => {
119+
const zip = new StreamZip({
120+
file: tempFilePath,
121+
storeEntries: true
119122
});
120-
await deferred.promise;
123+
124+
let totalFiles = 0;
125+
let extractedFiles = 0;
126+
zip.on('ready', () => {
127+
totalFiles = zip.entriesCount;
128+
if (!fs.existsSync(installFolder)) {
129+
fs.mkdirSync(installFolder);
130+
}
131+
zip.extract(null, installFolder, (err, count) => {
132+
if (err) {
133+
deferred.reject(err);
134+
} else {
135+
deferred.resolve();
136+
}
137+
zip.close();
138+
});
139+
}).on('extract', (entry, file) => {
140+
extractedFiles += 1;
141+
progress.report({ message: `${title}${Math.round(100 * extractedFiles / totalFiles)}%` });
142+
});
143+
return deferred.promise;
144+
});
121145
this.output.append('done.');
122146

123147
// Set file to executable

0 commit comments

Comments
 (0)