Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 37 additions & 26 deletions src/vs/platform/update/electron-main/updateService.win32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,36 +353,47 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
this.availableUpdate.cancelFilePath = cancelFilePath;

await pfs.Promises.writeFile(this.availableUpdate.updateFilePath, 'flag');
const child = spawn(this.availableUpdate.packagePath,
[
'/verysilent',
'/log',
`/update="${this.availableUpdate.updateFilePath}"`,
`/progress="${progressFilePath}"`,
`/sessionend="${sessionEndFlagPath}"`,
`/cancel="${cancelFilePath}"`,
'/nocloseapplications',
'/mergetasks=runcode,!desktopicon,!quicklaunchicon'
],
{
detached: true,
stdio: ['ignore', 'ignore', 'ignore'],
windowsVerbatimArguments: true,
env: { ...process.env, __COMPAT_LAYER: 'RunAsInvoker' }
}
);

// Track the process so we can cancel it if needed
this.availableUpdate.updateProcess = child;

child.once('exit', () => {
this.availableUpdate = undefined;
this.setState(State.Idle(getUpdateType()));
});

const readyMutexName = `${this.productService.win32MutexName}-ready`;
const updatingMutexName = `${this.productService.win32MutexName}-updating`;
const mutex = await import('@vscode/windows-mutex');

// Another VS Code instance may have already launched the Inno Setup installer
// for the same update. Spawning a second one races into Inno's "Setup is
// already running" modal. Skip the spawn and rely on the `-ready` mutex
// polling below to advance our own state machine when the install finishes.
const alreadyInstalling = mutex.isActive(updatingMutexName);
if (alreadyInstalling) {
Comment thread
dmitrivMS marked this conversation as resolved.
Outdated
this.logService.info('update#doApplyUpdate: another instance is already running setup, waiting for it to finish');
} else {
Comment thread
dmitrivMS marked this conversation as resolved.
const child = spawn(this.availableUpdate.packagePath,
[
'/verysilent',
'/log',
`/update="${this.availableUpdate.updateFilePath}"`,
`/progress="${progressFilePath}"`,
`/sessionend="${sessionEndFlagPath}"`,
`/cancel="${cancelFilePath}"`,
'/nocloseapplications',
'/mergetasks=runcode,!desktopicon,!quicklaunchicon'
],
{
detached: true,
stdio: ['ignore', 'ignore', 'ignore'],
windowsVerbatimArguments: true,
env: { ...process.env, __COMPAT_LAYER: 'RunAsInvoker' }
}
);

// Track the process so we can cancel it if needed
this.availableUpdate.updateProcess = child;

child.once('exit', () => {
this.availableUpdate = undefined;
this.setState(State.Idle(getUpdateType()));
});
}

this.updateCancellationTokenSource?.dispose(true);
const cts = this.updateCancellationTokenSource = new CancellationTokenSource();
const token = cts.token;
Expand Down
Loading