mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 17:23:45 -05:00
Merge from master
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import product from 'vs/platform/node/product';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
|
||||
@@ -15,8 +13,11 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { createUpdateURL, AbstractUpdateService } from 'vs/platform/update/electron-main/abstractUpdateService';
|
||||
import { asJson } from 'vs/base/node/request';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { shell } from 'electron';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import * as path from 'path';
|
||||
import { spawn } from 'child_process';
|
||||
import { realpath } from 'fs';
|
||||
|
||||
export class LinuxUpdateService extends AbstractUpdateService {
|
||||
|
||||
@@ -44,45 +45,89 @@ export class LinuxUpdateService extends AbstractUpdateService {
|
||||
|
||||
this.setState(State.CheckingForUpdates(context));
|
||||
|
||||
this.requestService.request({ url: this.url })
|
||||
.then<IUpdate>(asJson)
|
||||
.then(update => {
|
||||
if (!update || !update.url || !update.version || !update.productVersion) {
|
||||
if (process.env.SNAP && process.env.SNAP_REVISION) {
|
||||
this.checkForSnapUpdate();
|
||||
} else {
|
||||
this.requestService.request({ url: this.url }, CancellationToken.None)
|
||||
.then<IUpdate>(asJson)
|
||||
.then(update => {
|
||||
if (!update || !update.url || !update.version || !update.productVersion) {
|
||||
/* __GDPR__
|
||||
"update:notAvailable" : {
|
||||
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('update:notAvailable', { explicit: !!context });
|
||||
|
||||
this.setState(State.Idle(UpdateType.Archive));
|
||||
} else {
|
||||
this.setState(State.AvailableForDownload(update));
|
||||
}
|
||||
})
|
||||
.then(null, err => {
|
||||
this.logService.error(err);
|
||||
|
||||
/* __GDPR__
|
||||
"update:notAvailable" : {
|
||||
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
}
|
||||
"update:notAvailable" : {
|
||||
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('update:notAvailable', { explicit: !!context });
|
||||
|
||||
this.setState(State.Idle(UpdateType.Archive));
|
||||
} else {
|
||||
this.setState(State.AvailableForDownload(update));
|
||||
}
|
||||
})
|
||||
.then(null, err => {
|
||||
this.logService.error(err);
|
||||
|
||||
/* __GDPR__
|
||||
"update:notAvailable" : {
|
||||
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('update:notAvailable', { explicit: !!context });
|
||||
this.setState(State.Idle(UpdateType.Archive));
|
||||
});
|
||||
// only show message when explicitly checking for updates
|
||||
const message: string | undefined = !!context ? (err.message || err) : undefined;
|
||||
this.setState(State.Idle(UpdateType.Archive, message));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected doDownloadUpdate(state: AvailableForDownload): TPromise<void> {
|
||||
private checkForSnapUpdate(): void {
|
||||
// If the application was installed as a snap, updates happen in the
|
||||
// background automatically, we just need to check to see if an update
|
||||
// has already happened.
|
||||
realpath(`${path.dirname(process.env.SNAP!)}/current`, (err, resolvedCurrentSnapPath) => {
|
||||
if (err) {
|
||||
this.logService.error('update#checkForSnapUpdate(): Could not get realpath of application.');
|
||||
return;
|
||||
}
|
||||
|
||||
const currentRevision = path.basename(resolvedCurrentSnapPath);
|
||||
|
||||
if (process.env.SNAP_REVISION !== currentRevision) {
|
||||
// TODO@joao: snap
|
||||
this.setState(State.Ready({ version: '', productVersion: '' }));
|
||||
} else {
|
||||
this.setState(State.Idle(UpdateType.Archive));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected async doDownloadUpdate(state: AvailableForDownload): Promise<void> {
|
||||
// Use the download URL if available as we don't currently detect the package type that was
|
||||
// installed and the website download page is more useful than the tarball generally.
|
||||
if (product.downloadUrl && product.downloadUrl.length > 0) {
|
||||
shell.openExternal(product.downloadUrl);
|
||||
} else {
|
||||
} else if (state.update.url) {
|
||||
shell.openExternal(state.update.url);
|
||||
}
|
||||
|
||||
this.setState(State.Idle(UpdateType.Archive));
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
protected doQuitAndInstall(): void {
|
||||
this.logService.trace('update#quitAndInstall(): running raw#quitAndInstall()');
|
||||
|
||||
const snap = process.env.SNAP;
|
||||
|
||||
// TODO@joao what to do?
|
||||
if (!snap) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow 3 seconds for VS Code to close
|
||||
spawn('bash', ['-c', path.join(snap, `usr/share/${product.applicationName}/snapUpdate.sh`)], {
|
||||
detached: true,
|
||||
stdio: ['ignore', 'ignore', 'ignore']
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user