mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
fix downloading state in darwin (#206960)
* fix downloading state in darwin * do not show user forced update notification in specific cases --------- Co-authored-by: João Moreno <joao.moreno@microsoft.com>
This commit is contained in:
parent
b92a5dd3f0
commit
639b71bdce
|
@ -64,7 +64,7 @@ export type Disabled = { type: StateType.Disabled; reason: DisablementReason };
|
|||
export type Idle = { type: StateType.Idle; updateType: UpdateType; error?: string };
|
||||
export type CheckingForUpdates = { type: StateType.CheckingForUpdates; explicit: boolean };
|
||||
export type AvailableForDownload = { type: StateType.AvailableForDownload; update: IUpdate };
|
||||
export type Downloading = { type: StateType.Downloading; update: IUpdate };
|
||||
export type Downloading = { type: StateType.Downloading };
|
||||
export type Downloaded = { type: StateType.Downloaded; update: IUpdate };
|
||||
export type Updating = { type: StateType.Updating; update: IUpdate };
|
||||
export type Ready = { type: StateType.Ready; update: IUpdate };
|
||||
|
@ -77,7 +77,7 @@ export const State = {
|
|||
Idle: (updateType: UpdateType, error?: string) => ({ type: StateType.Idle, updateType, error }) as Idle,
|
||||
CheckingForUpdates: (explicit: boolean) => ({ type: StateType.CheckingForUpdates, explicit } as CheckingForUpdates),
|
||||
AvailableForDownload: (update: IUpdate) => ({ type: StateType.AvailableForDownload, update } as AvailableForDownload),
|
||||
Downloading: (update: IUpdate) => ({ type: StateType.Downloading, update } as Downloading),
|
||||
Downloading: { type: StateType.Downloading } as Downloading,
|
||||
Downloaded: (update: IUpdate) => ({ type: StateType.Downloaded, update } as Downloaded),
|
||||
Updating: (update: IUpdate) => ({ type: StateType.Updating, update } as Updating),
|
||||
Ready: (update: IUpdate) => ({ type: StateType.Ready, update } as Ready),
|
||||
|
|
|
@ -24,7 +24,7 @@ export class DarwinUpdateService extends AbstractUpdateService implements IRelau
|
|||
|
||||
@memoize private get onRawError(): Event<string> { return Event.fromNodeEventEmitter(electron.autoUpdater, 'error', (_, message) => message); }
|
||||
@memoize private get onRawUpdateNotAvailable(): Event<void> { return Event.fromNodeEventEmitter<void>(electron.autoUpdater, 'update-not-available'); }
|
||||
@memoize private get onRawUpdateAvailable(): Event<IUpdate> { return Event.fromNodeEventEmitter(electron.autoUpdater, 'update-available', (_, url, version, timestamp) => ({ url, version, productVersion: version, timestamp })); }
|
||||
@memoize private get onRawUpdateAvailable(): Event<void> { return Event.fromNodeEventEmitter(electron.autoUpdater, 'update-available'); }
|
||||
@memoize private get onRawUpdateDownloaded(): Event<IUpdate> { return Event.fromNodeEventEmitter(electron.autoUpdater, 'update-downloaded', (_, releaseNotes, version, timestamp) => ({ version, productVersion: version, timestamp })); }
|
||||
|
||||
constructor(
|
||||
|
@ -96,12 +96,12 @@ export class DarwinUpdateService extends AbstractUpdateService implements IRelau
|
|||
electron.autoUpdater.checkForUpdates();
|
||||
}
|
||||
|
||||
private onUpdateAvailable(update: IUpdate): void {
|
||||
private onUpdateAvailable(): void {
|
||||
if (this.state.type !== StateType.CheckingForUpdates) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState(State.Downloading(update));
|
||||
this.setState(State.Downloading);
|
||||
}
|
||||
|
||||
private onUpdateDownloaded(update: IUpdate): void {
|
||||
|
|
|
@ -135,7 +135,7 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
|
|||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
this.setState(State.Downloading(update));
|
||||
this.setState(State.Downloading);
|
||||
|
||||
return this.cleanup(update.version).then(() => {
|
||||
return this.getUpdatePackagePath(update.version).then(updatePackagePath => {
|
||||
|
@ -153,15 +153,13 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
|
|||
.then(() => updatePackagePath);
|
||||
});
|
||||
}).then(packagePath => {
|
||||
const fastUpdatesEnabled = this.configurationService.getValue('update.enableWindowsBackgroundUpdates');
|
||||
|
||||
this.availableUpdate = { packagePath };
|
||||
this.setState(State.Downloaded(update));
|
||||
|
||||
const fastUpdatesEnabled = this.configurationService.getValue('update.enableWindowsBackgroundUpdates');
|
||||
if (fastUpdatesEnabled) {
|
||||
if (this.productService.target === 'user') {
|
||||
this.doApplyUpdate();
|
||||
} else {
|
||||
this.setState(State.Downloaded(update));
|
||||
}
|
||||
} else {
|
||||
this.setState(State.Ready(update));
|
||||
|
@ -209,7 +207,7 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
|
|||
}
|
||||
|
||||
protected override async doApplyUpdate(): Promise<void> {
|
||||
if (this.state.type !== StateType.Downloaded && this.state.type !== StateType.Downloading) {
|
||||
if (this.state.type !== StateType.Downloaded) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
|
@ -273,14 +271,13 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
|
|||
const fastUpdatesEnabled = this.configurationService.getValue('update.enableWindowsBackgroundUpdates');
|
||||
const update: IUpdate = { version: 'unknown', productVersion: 'unknown' };
|
||||
|
||||
this.setState(State.Downloading(update));
|
||||
this.setState(State.Downloading);
|
||||
this.availableUpdate = { packagePath };
|
||||
this.setState(State.Downloaded(update));
|
||||
|
||||
if (fastUpdatesEnabled) {
|
||||
if (this.productService.target === 'user') {
|
||||
this.doApplyUpdate();
|
||||
} else {
|
||||
this.setState(State.Downloaded(update));
|
||||
}
|
||||
} else {
|
||||
this.setState(State.Ready(update));
|
||||
|
|
|
@ -173,6 +173,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
|
|||
@IContextKeyService private readonly contextKeyService: IContextKeyService,
|
||||
@IProductService private readonly productService: IProductService,
|
||||
@IOpenerService private readonly openerService: IOpenerService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IHostService private readonly hostService: IHostService
|
||||
) {
|
||||
super();
|
||||
|
@ -316,8 +317,12 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
|
|||
);
|
||||
}
|
||||
|
||||
// windows fast updates (target === system)
|
||||
// windows fast updates
|
||||
private onUpdateDownloaded(update: IUpdate): void {
|
||||
if (this.configurationService.getValue('update.enableWindowsBackgroundUpdates') && this.productService.target === 'user') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.shouldShowNotification()) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue