win32 update service should notify url update on zip

fixes #52225
This commit is contained in:
Joao Moreno
2018-06-27 15:12:43 +02:00
parent 0e87ea1c5e
commit c6f2eacce8
2 changed files with 32 additions and 7 deletions
@@ -84,8 +84,8 @@ export class LinuxUpdateService extends AbstractUpdateService {
} else {
shell.openExternal(state.update.url);
}
this.setState(State.Idle);
this.setState(State.Idle);
return TPromise.as(null);
}
}
@@ -14,7 +14,7 @@ import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycle
import { IRequestService } from 'vs/platform/request/node/request';
import product from 'vs/platform/node/product';
import { TPromise, Promise } from 'vs/base/common/winjs.base';
import { State, IUpdate, StateType } from 'vs/platform/update/common/update';
import { State, IUpdate, StateType, AvailableForDownload } from 'vs/platform/update/common/update';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ILogService } from 'vs/platform/log/common/log';
@@ -23,6 +23,7 @@ import { download, asJson } from 'vs/base/node/request';
import { checksum } from 'vs/base/node/crypto';
import { tmpdir } from 'os';
import { spawn } from 'child_process';
import { shell } from 'electron';
function pollUntil(fn: () => boolean, timeout = 1000): TPromise<void> {
return new TPromise<void>(c => {
@@ -43,12 +44,18 @@ interface IAvailableUpdate {
updateFilePath?: string;
}
enum UpdateType {
Automatic,
Manual
}
export class Win32UpdateService extends AbstractUpdateService {
_serviceBrand: any;
private url: string | undefined;
private availableUpdate: IAvailableUpdate | undefined;
private updateType: UpdateType;
@memoize
get cachePath(): TPromise<string> {
@@ -65,13 +72,13 @@ export class Win32UpdateService extends AbstractUpdateService {
@ILogService logService: ILogService
) {
super(lifecycleService, configurationService, environmentService, logService);
this.updateType = fs.existsSync(path.join(path.dirname(process.execPath), 'unins000.exe'))
? UpdateType.Automatic
: UpdateType.Manual;
}
protected setUpdateFeedUrl(quality: string): boolean {
if (!fs.existsSync(path.join(path.dirname(process.execPath), 'unins000.exe'))) {
return false;
}
let platform = 'win32';
if (process.arch === 'x64') {
@@ -96,7 +103,7 @@ export class Win32UpdateService extends AbstractUpdateService {
this.requestService.request({ url: this.url })
.then<IUpdate>(asJson)
.then(update => {
if (!update || !update.url || !update.version) {
if (!update || !update.url || !update.version || !update.productVersion) {
/* __GDPR__
"update:notAvailable" : {
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
@@ -108,6 +115,11 @@ export class Win32UpdateService extends AbstractUpdateService {
return TPromise.as(null);
}
if (this.updateType === UpdateType.Manual) {
this.setState(State.AvailableForDownload(update));
return TPromise.as(null);
}
this.setState(State.Downloading(update));
return this.cleanup(update.version).then(() => {
@@ -156,6 +168,19 @@ export class Win32UpdateService extends AbstractUpdateService {
});
}
protected doDownloadUpdate(state: AvailableForDownload): TPromise<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 {
shell.openExternal(state.update.url);
}
this.setState(State.Idle);
return TPromise.as(null);
}
private getUpdatePackagePath(version: string): TPromise<string> {
return this.cachePath.then(cachePath => path.join(cachePath, `CodeSetup-${product.quality}-${version}.exe`));
}