From 5a8934a1d5d0e7a663ef6da38ca14605060f1e2d Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 1 Feb 2018 14:51:00 -0800 Subject: [PATCH] use proper zip command on windows --- src/vs/code/electron-main/logUploader.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/vs/code/electron-main/logUploader.ts b/src/vs/code/electron-main/logUploader.ts index 87425685c5bf2..543fab3fb4112 100644 --- a/src/vs/code/electron-main/logUploader.ts +++ b/src/vs/code/electron-main/logUploader.ts @@ -124,7 +124,7 @@ function zipLogs( const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'vscode-log-upload')); const outZip = path.join(tempDir, 'logs.zip'); return new TPromise((resolve, reject) => { - doZip(logsPath, outZip, (err, stdout, stderr) => { + doZip(logsPath, outZip, tempDir, (err, stdout, stderr) => { if (err) { console.error(localize('zipError', 'Error zipping logs: {0}', err)); reject(err); @@ -138,12 +138,17 @@ function zipLogs( function doZip( logsPath: string, outZip: string, + tempDir: string, callback: (error: Error, stdout: string, stderr: string) => void ) { switch (os.platform()) { case 'win32': - return cp.execFile('powershell', ['-Command', `Compress-Archive -Path "${logsPath}" -DestinationPath ${outZip}`], { cwd: logsPath }, callback); - + // Copy directory first to avoid file locking issues + const sub = path.join(tempDir, 'sub'); + return cp.execFile('powershell', ['-Command', + `[System.IO.Directory]::CreateDirectory("${sub}"); Copy-Item -recurse "${logsPath}" "${sub}"; Compress-Archive -Path "${sub}" -DestinationPath "${outZip}"`], + { cwd: logsPath }, + callback); default: return cp.execFile('zip', ['-r', outZip, '.'], { cwd: logsPath }, callback); }