提交 764cd960 编写于 作者: S Sandeep Somavarapu

Fix #68208

上级 6850012c
......@@ -319,8 +319,6 @@
"./vs/platform/menubar/node/menubarIpc.ts",
"./vs/platform/node/package.ts",
"./vs/platform/node/product.ts",
"./vs/platform/node/test/zip.test.ts",
"./vs/platform/node/zip.ts",
"./vs/platform/notification/common/notification.ts",
"./vs/platform/notification/test/common/testNotificationService.ts",
"./vs/platform/opener/common/opener.ts",
......
......@@ -6,10 +6,9 @@
import * as assert from 'assert';
import * as path from 'vs/base/common/path';
import * as os from 'os';
import { extract } from 'vs/platform/node/zip';
import { extract } from 'vs/base/node/zip';
import { generateUuid } from 'vs/base/common/uuid';
import { rimraf, exists } from 'vs/base/node/pfs';
import { NullLogService } from 'vs/platform/log/common/log';
import { getPathFromAmdModule } from 'vs/base/common/amd';
import { createCancelablePromise } from 'vs/base/common/async';
......@@ -21,7 +20,7 @@ suite('Zip', () => {
const fixture = path.join(fixtures, 'extract.zip');
const target = path.join(os.tmpdir(), generateUuid());
return createCancelablePromise(token => extract(fixture, target, {}, new NullLogService(), token)
return createCancelablePromise(token => extract(fixture, target, {}, token)
.then(() => exists(path.join(target, 'extension')))
.then(exists => assert(exists))
.then(() => rimraf(target)));
......
......@@ -11,14 +11,13 @@ import { nfcall, ninvoke, Sequencer, createCancelablePromise } from 'vs/base/com
import { mkdirp, rimraf } from 'vs/base/node/pfs';
import { open as _openZip, Entry, ZipFile } from 'yauzl';
import * as yazl from 'yazl';
import { ILogService } from 'vs/platform/log/common/log';
import { CancellationToken } from 'vs/base/common/cancellation';
import { Event } from 'vs/base/common/event';
export interface IExtractOptions {
overwrite?: boolean;
/**
/**
* Source path within the ZIP archive. Only the files contained in this
* path will be extracted.
*/
......@@ -104,12 +103,11 @@ function extractEntry(stream: Readable, fileName: string, mode: number, targetPa
}));
}
function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions, logService: ILogService, token: CancellationToken): Promise<void> {
function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions, token: CancellationToken): Promise<void> {
let last = createCancelablePromise<void>(() => Promise.resolve());
let extractedEntriesCount = 0;
Event.once(token.onCancellationRequested)(() => {
logService.debug(targetPath, 'Cancelled.');
last.cancel();
zipfile.close();
});
......@@ -195,7 +193,7 @@ export function zip(zipPath: string, files: IFile[]): Promise<string> {
});
}
export function extract(zipPath: string, targetPath: string, options: IExtractOptions = {}, logService: ILogService, token: CancellationToken): Promise<void> {
export function extract(zipPath: string, targetPath: string, options: IExtractOptions = {}, token: CancellationToken): Promise<void> {
const sourcePathRegex = new RegExp(options.sourcePath ? `^${options.sourcePath}` : '');
let promise = openZip(zipPath, true);
......@@ -204,7 +202,7 @@ export function extract(zipPath: string, targetPath: string, options: IExtractOp
promise = promise.then(zipfile => rimraf(targetPath).then(() => zipfile));
}
return promise.then(zipfile => extractZip(zipfile, targetPath, { sourcePathRegex }, logService, token));
return promise.then(zipfile => extractZip(zipfile, targetPath, { sourcePathRegex }, token));
}
function read(zipPath: string, filePath: string): Promise<Readable> {
......
......@@ -9,7 +9,7 @@ import * as pfs from 'vs/base/node/pfs';
import { assign } from 'vs/base/common/objects';
import { toDisposable, Disposable } from 'vs/base/common/lifecycle';
import { flatten } from 'vs/base/common/arrays';
import { extract, ExtractError, zip, IFile } from 'vs/platform/node/zip';
import { extract, ExtractError, zip, IFile } from 'vs/base/node/zip';
import {
IExtensionManagementService, IExtensionGalleryService, ILocalExtension,
IGalleryExtension, IGalleryMetadata,
......@@ -472,7 +472,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
this.logService.trace(`Started extracting the extension from ${zipPath} to ${extractPath}`);
return pfs.rimraf(extractPath)
.then(
() => extract(zipPath, extractPath, { sourcePath: 'extension', overwrite: true }, this.logService, token)
() => extract(zipPath, extractPath, { sourcePath: 'extension', overwrite: true }, token)
.then(
() => this.logService.info(`Extracted extension to ${extractPath}:`, identifier.id),
e => pfs.rimraf(extractPath).finally(() => null)
......
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { buffer } from 'vs/platform/node/zip';
import { buffer } from 'vs/base/node/zip';
import { localize } from 'vs/nls';
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册