Skip to content

Commit

Permalink
Replace unzip package (#1419)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Mikhail Arkhipov authored Apr 17, 2018
1 parent 39612b4 commit df72cac
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,7 @@
"md5": "2.2.1",
"minimatch": "3.0.4",
"named-js-regexp": "1.3.3",
"node-stream-zip": "^1.6.0",
"opn": "5.3.0",
"pidusage": "1.2.0",
"reflect-metadata": "0.1.12",
Expand All @@ -1862,7 +1863,6 @@
"uint64be": "1.0.1",
"unicode": "10.0.0",
"untildify": "3.0.2",
"unzip": "0.1.11",
"vscode-debugadapter": "1.28.0",
"vscode-debugprotocol": "1.28.0",
"vscode-extension-telemetry": "0.0.15",
Expand Down
42 changes: 33 additions & 9 deletions src/client/activation/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as fs from 'fs';
import * as path from 'path';
import * as request from 'request';
import * as requestProgress from 'request-progress';
import * as unzip from 'unzip';
import { ExtensionContext, OutputChannel, ProgressLocation, window } from 'vscode';
import { STANDARD_OUTPUT_CHANNEL } from '../common/constants';
import { noop } from '../common/core.utils';
Expand All @@ -16,6 +15,9 @@ import { IServiceContainer } from '../ioc/types';
import { HashVerifier } from './hashVerifier';
import { PlatformData } from './platformData';

// tslint:disable-next-line:no-require-imports no-var-requires
const StreamZip = require('node-stream-zip');

const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-analysis';
const downloadBaseFileName = 'python-analysis-vscode';
const downloadVersion = '0.1.0';
Expand Down Expand Up @@ -109,15 +111,37 @@ export class AnalysisEngineDownloader {
const installFolder = path.join(extensionPath, this.engineFolder);
const deferred = createDeferred();

fs.createReadStream(tempFilePath)
.pipe(unzip.Extract({ path: installFolder }))
.on('finish', () => {
deferred.resolve();
})
.on('error', (err) => {
deferred.reject(err);
const title = 'Extracting files... ';
await window.withProgress({
location: ProgressLocation.Window,
title
}, (progress) => {
const zip = new StreamZip({
file: tempFilePath,
storeEntries: true
});
await deferred.promise;

let totalFiles = 0;
let extractedFiles = 0;
zip.on('ready', () => {
totalFiles = zip.entriesCount;
if (!fs.existsSync(installFolder)) {
fs.mkdirSync(installFolder);
}
zip.extract(null, installFolder, (err, count) => {
if (err) {
deferred.reject(err);
} else {
deferred.resolve();
}
zip.close();
});
}).on('extract', (entry, file) => {
extractedFiles += 1;
progress.report({ message: `${title}${Math.round(100 * extractedFiles / totalFiles)}%` });
});
return deferred.promise;
});
this.output.append('done.');

// Set file to executable
Expand Down

0 comments on commit df72cac

Please sign in to comment.