From a24e1badcd9c54f6534c4920054d368d6846dd16 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Wed, 19 Sep 2018 16:13:58 +0200 Subject: [PATCH] #49289 Fix Error handling --- src/vs/platform/node/zip.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/vs/platform/node/zip.ts b/src/vs/platform/node/zip.ts index d84133cb68d..af8243dc3a3 100644 --- a/src/vs/platform/node/zip.ts +++ b/src/vs/platform/node/zip.ts @@ -93,11 +93,15 @@ function extractEntry(stream: Readable, fileName: string, mode: number, targetPa return; } - istream = createWriteStream(targetFileName, { mode }); - istream.once('close', () => c(null)); - istream.once('error', e); - stream.once('error', e); - stream.pipe(istream); + try { + istream = createWriteStream(targetFileName, { mode }); + istream.once('close', () => c(null)); + istream.once('error', e); + stream.once('error', e); + stream.pipe(istream); + } catch (error) { + e(error); + } })); } @@ -148,14 +152,14 @@ function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions, log // directory file names end with '/' if (/\/$/.test(fileName)) { const targetFileName = path.join(targetPath, fileName); - last = createCancelablePromise(token => mkdirp(targetFileName, void 0, token).then(() => readNextEntry(token))); + last = createCancelablePromise(token => mkdirp(targetFileName, void 0, token).then(() => readNextEntry(token)).then(null, e)); return; } const stream = ninvoke(zipfile, zipfile.openReadStream, entry); const mode = modeFromEntry(entry); - last = createCancelablePromise(token => throttler.queue(() => stream.then(stream => extractEntry(stream, fileName, mode, targetPath, options, token).then(() => readNextEntry(token))))); + last = createCancelablePromise(token => throttler.queue(() => stream.then(stream => extractEntry(stream, fileName, mode, targetPath, options, token).then(() => readNextEntry(token)))).then(null, e)); }); }); } -- GitLab