Skip to content

Commit

Permalink
Remove hardcoded update service participation (#176429)
Browse files Browse the repository at this point in the history
* Remove hardcoded update service participation

fixes #160135

* fix protected fields

* remove race
  • Loading branch information
joaomoreno authored Mar 9, 2023
1 parent 91163a9 commit 8aef575
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
6 changes: 0 additions & 6 deletions src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,6 @@ export class CodeApplication extends Disposable {

private afterWindowOpen(accessor: ServicesAccessor, sharedProcess: SharedProcess): void {
const telemetryService = accessor.get(ITelemetryService);
const updateService = accessor.get(IUpdateService);

// Observe shared process for errors
this.handleSharedProcessErrors(telemetryService, sharedProcess);
Expand All @@ -1212,11 +1211,6 @@ export class CodeApplication extends Disposable {
});
});

// Initialize update service
if (updateService instanceof Win32UpdateService || updateService instanceof LinuxUpdateService || updateService instanceof DarwinUpdateService) {
updateService.initialize();
}

// Start to fetch shell environment (if needed) after window has opened
// Since this operation can take a long time, we want to warm it up while
// the window is opening.
Expand Down
9 changes: 6 additions & 3 deletions src/vs/platform/update/electron-main/abstractUpdateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { Emitter, Event } from 'vs/base/common/event';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService';
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { ILogService } from 'vs/platform/log/common/log';
import { IProductService } from 'vs/platform/product/common/productService';
import { IRequestService } from 'vs/platform/request/common/request';
Expand Down Expand Up @@ -52,14 +52,17 @@ export abstract class AbstractUpdateService implements IUpdateService {
@IRequestService protected requestService: IRequestService,
@ILogService protected logService: ILogService,
@IProductService protected readonly productService: IProductService
) { }
) {
lifecycleMainService.when(LifecycleMainPhase.AfterWindowOpen)
.finally(() => this.initialize());
}

/**
* This must be called before any other call. This is a performance
* optimization, to avoid using extra CPU cycles before first window open.
* https://github.com/microsoft/vscode/issues/89784
*/
async initialize(): Promise<void> {
protected async initialize(): Promise<void> {
if (!this.environmentMainService.isBuilt) {
return; // updates are never enabled when running out of sources
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class DarwinUpdateService extends AbstractUpdateService {
super(lifecycleMainService, configurationService, environmentMainService, requestService, logService, productService);
}

override async initialize(): Promise<void> {
protected override async initialize(): Promise<void> {
await super.initialize();
this.onRawError(this.onError, this, this.disposables);
this.onRawUpdateAvailable(this.onUpdateAvailable, this, this.disposables);
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/update/electron-main/updateService.win32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ export class Win32UpdateService extends AbstractUpdateService {
super(lifecycleMainService, configurationService, environmentMainService, requestService, logService, productService);
}

override async initialize(): Promise<void> {
protected override async initialize(): Promise<void> {
if (this.productService.target === 'user' && await this.nativeHostMainService.isAdmin(undefined)) {
this.logService.info('update#ctor - updates are disabled due to running as Admin in user setup');
return;
}

super.initialize();
await super.initialize();
}

protected buildUpdateFeedUrl(quality: string): string | undefined {
Expand Down

0 comments on commit 8aef575

Please sign in to comment.