mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-05 09:35:39 -05:00
* Merge from vscode fcf3346a8e9f5ee1e00674461d9e2c2292a14ee3 * Fix test build break * Update distro * Fix build errors * Update distro * Update REH build file * Update build task names for REL * Fix product build yaml * Fix product REH task name * Fix type in task name * Update linux build step * Update windows build tasks * Turn off server publish * Disable REH * Fix typo * Bump distro * Update vscode tests * Bump distro * Fix type in disto * Bump distro * Turn off docker build * Remove docker step from release Co-authored-by: ADS Merger <andresse@microsoft.com> Co-authored-by: Karl Burtram <karlb@microsoft.com>
114 lines
4.9 KiB
TypeScript
114 lines
4.9 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as electron from 'electron';
|
|
import { DisposableStore } from 'vs/base/common/lifecycle';
|
|
import { Event } from 'vs/base/common/event';
|
|
import { memoize } from 'vs/base/common/decorators';
|
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
|
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
|
|
import { State, IUpdate, StateType, UpdateType } from 'vs/platform/update/common/update';
|
|
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
|
import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment';
|
|
import { ILogService } from 'vs/platform/log/common/log';
|
|
import { AbstractUpdateService, createUpdateURL, UpdateNotAvailableClassification } from 'vs/platform/update/electron-main/abstractUpdateService';
|
|
import { IRequestService } from 'vs/platform/request/common/request';
|
|
|
|
export class DarwinUpdateService extends AbstractUpdateService {
|
|
|
|
declare readonly _serviceBrand: undefined;
|
|
|
|
private readonly disposables = new DisposableStore();
|
|
|
|
@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) => ({ url, version, productVersion: version })); }
|
|
@memoize private get onRawUpdateDownloaded(): Event<IUpdate> { return Event.fromNodeEventEmitter(electron.autoUpdater, 'update-downloaded', (_, releaseNotes, version, date) => ({ releaseNotes, version, productVersion: version, date })); }
|
|
|
|
constructor(
|
|
@ILifecycleMainService lifecycleMainService: ILifecycleMainService,
|
|
@IConfigurationService configurationService: IConfigurationService,
|
|
@ITelemetryService private readonly telemetryService: ITelemetryService,
|
|
@IEnvironmentService environmentService: INativeEnvironmentService,
|
|
@IRequestService requestService: IRequestService,
|
|
@ILogService logService: ILogService
|
|
) {
|
|
super(lifecycleMainService, configurationService, environmentService, requestService, logService);
|
|
}
|
|
|
|
initialize(): void {
|
|
super.initialize();
|
|
this.onRawError(this.onError, this, this.disposables);
|
|
this.onRawUpdateAvailable(this.onUpdateAvailable, this, this.disposables);
|
|
this.onRawUpdateDownloaded(this.onUpdateDownloaded, this, this.disposables);
|
|
this.onRawUpdateNotAvailable(this.onUpdateNotAvailable, this, this.disposables);
|
|
}
|
|
|
|
private onError(err: string): void {
|
|
this.logService.error('UpdateService error:', err);
|
|
|
|
// only show message when explicitly checking for updates
|
|
const shouldShowMessage = this.state.type === StateType.CheckingForUpdates ? !!this.state.context : true;
|
|
const message: string | undefined = shouldShowMessage ? err : undefined;
|
|
this.setState(State.Idle(UpdateType.Archive, message));
|
|
}
|
|
|
|
protected buildUpdateFeedUrl(quality: string): string | undefined {
|
|
const url = createUpdateURL('darwin', quality);
|
|
try {
|
|
electron.autoUpdater.setFeedURL({ url });
|
|
} catch (e) {
|
|
// application is very likely not signed
|
|
this.logService.error('Failed to set update feed URL', e);
|
|
return undefined;
|
|
}
|
|
return url;
|
|
}
|
|
|
|
protected doCheckForUpdates(context: any): void {
|
|
this.setState(State.CheckingForUpdates(context));
|
|
electron.autoUpdater.checkForUpdates();
|
|
}
|
|
|
|
private onUpdateAvailable(update: IUpdate): void {
|
|
if (this.state.type !== StateType.CheckingForUpdates) {
|
|
return;
|
|
}
|
|
|
|
this.setState(State.Downloading(update));
|
|
}
|
|
|
|
private onUpdateDownloaded(update: IUpdate): void {
|
|
if (this.state.type !== StateType.Downloading) {
|
|
return;
|
|
}
|
|
|
|
type UpdateDownloadedClassification = {
|
|
version: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
|
|
};
|
|
this.telemetryService.publicLog2<{ version: String }, UpdateDownloadedClassification>('update:downloaded', { version: update.version });
|
|
|
|
this.setState(State.Ready(update));
|
|
}
|
|
|
|
private onUpdateNotAvailable(): void {
|
|
if (this.state.type !== StateType.CheckingForUpdates) {
|
|
return;
|
|
}
|
|
this.telemetryService.publicLog2<{ explicit: boolean }, UpdateNotAvailableClassification>('update:notAvailable', { explicit: !!this.state.context });
|
|
|
|
this.setState(State.Idle(UpdateType.Archive));
|
|
}
|
|
|
|
protected doQuitAndInstall(): void {
|
|
this.logService.trace('update#quitAndInstall(): running raw#quitAndInstall()');
|
|
electron.autoUpdater.quitAndInstall();
|
|
}
|
|
|
|
dispose(): void {
|
|
this.disposables.dispose();
|
|
}
|
|
}
|