Skip to content

Commit a9e16ba

Browse files
committed
microsoft#48373 Add logs
1 parent 675d4fb commit a9e16ba

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/vs/base/node/zip.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { nfcall, ninvoke, SimpleThrottler } from 'vs/base/common/async';
1111
import { mkdirp, rimraf } from 'vs/base/node/pfs';
1212
import { TPromise } from 'vs/base/common/winjs.base';
1313
import { open as _openZip, Entry, ZipFile } from 'yauzl';
14+
import { ILogService } from 'vs/platform/log/common/log';
1415

1516
export interface IExtractOptions {
1617
overwrite?: boolean;
@@ -87,7 +88,7 @@ function extractEntry(stream: Readable, fileName: string, mode: number, targetPa
8788
}));
8889
}
8990

90-
function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions): TPromise<void> {
91+
function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions, logService: ILogService): TPromise<void> {
9192
let isCanceled = false;
9293
let last = TPromise.wrap<any>(null);
9394
let extractedEntriesCount = 0;
@@ -108,6 +109,8 @@ function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions): TP
108109
return;
109110
}
110111

112+
logService.debug(targetPath, 'Extracting', entry.fileName);
113+
111114
if (!options.sourcePathRegex.test(entry.fileName)) {
112115
extractedEntriesCount++;
113116
return;
@@ -139,7 +142,7 @@ function openZip(zipFile: string): TPromise<ZipFile> {
139142
.then(null, err => TPromise.wrapError(toExtractError(err)));
140143
}
141144

142-
export function extract(zipPath: string, targetPath: string, options: IExtractOptions = {}): TPromise<void> {
145+
export function extract(zipPath: string, targetPath: string, options: IExtractOptions = {}, logService: ILogService): TPromise<void> {
143146
const sourcePathRegex = new RegExp(options.sourcePath ? `^${options.sourcePath}` : '');
144147

145148
let promise = openZip(zipPath);
@@ -148,7 +151,7 @@ export function extract(zipPath: string, targetPath: string, options: IExtractOp
148151
promise = promise.then(zipfile => rimraf(targetPath).then(() => zipfile));
149152
}
150153

151-
return promise.then(zipfile => extractZip(zipfile, targetPath, { sourcePathRegex }));
154+
return promise.then(zipfile => extractZip(zipfile, targetPath, { sourcePathRegex }, logService));
152155
}
153156

154157
function read(zipPath: string, filePath: string): TPromise<Readable> {

src/vs/base/test/node/zip/zip.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import URI from 'vs/base/common/uri';
1212
import { extract } from 'vs/base/node/zip';
1313
import { generateUuid } from 'vs/base/common/uuid';
1414
import { rimraf, exists } from 'vs/base/node/pfs';
15+
import { NullLogService } from '../../../../platform/log/common/log';
1516

1617
const fixtures = URI.parse(require.toUrl('./fixtures')).fsPath;
1718

@@ -21,7 +22,7 @@ suite('Zip', () => {
2122
const fixture = path.join(fixtures, 'extract.zip');
2223
const target = path.join(os.tmpdir(), generateUuid());
2324

24-
return extract(fixture, target)
25+
return extract(fixture, target, {}, new NullLogService())
2526
.then(() => exists(path.join(target, 'extension')))
2627
.then(exists => assert(exists))
2728
.then(() => rimraf(target));

src/vs/platform/extensionManagement/node/extensionManagementService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
444444
this.logService.trace(`Started extracting the extension from ${zipPath} to ${extractPath}`);
445445
return pfs.rimraf(extractPath)
446446
.then(
447-
() => extract(zipPath, extractPath, { sourcePath: 'extension', overwrite: true })
447+
() => extract(zipPath, extractPath, { sourcePath: 'extension', overwrite: true }, this.logService)
448448
.then(
449449
() => this.logService.info(`Extracted extension to ${extractPath}:`, id),
450450
e => always(pfs.rimraf(extractPath), () => null)

0 commit comments

Comments
 (0)