Skip to content

Commit 663eca8

Browse files
committed
Removed Snap related code from updateService.linux.ts
Fixed updateService.snap to not execute process based on environment variable.
1 parent 9a72cf0 commit 663eca8

2 files changed

Lines changed: 26 additions & 69 deletions

File tree

src/vs/platform/update/electron-main/updateService.linux.ts

Lines changed: 25 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ import { createUpdateURL, AbstractUpdateService } from 'vs/platform/update/elect
1515
import { asJson } from 'vs/base/node/request';
1616
import { shell } from 'electron';
1717
import { CancellationToken } from 'vs/base/common/cancellation';
18-
import * as path from 'vs/base/common/path';
19-
import { spawn } from 'child_process';
20-
import { realpath } from 'fs';
2118

2219
export class LinuxUpdateService extends AbstractUpdateService {
2320

@@ -45,61 +42,36 @@ export class LinuxUpdateService extends AbstractUpdateService {
4542

4643
this.setState(State.CheckingForUpdates(context));
4744

48-
if (process.env.SNAP && process.env.SNAP_REVISION) {
49-
this.checkForSnapUpdate();
50-
} else {
51-
this.requestService.request({ url: this.url }, CancellationToken.None)
52-
.then<IUpdate>(asJson)
53-
.then(update => {
54-
if (!update || !update.url || !update.version || !update.productVersion) {
55-
/* __GDPR__
56-
"update:notAvailable" : {
57-
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
58-
}
59-
*/
60-
this.telemetryService.publicLog('update:notAvailable', { explicit: !!context });
61-
62-
this.setState(State.Idle(UpdateType.Archive));
63-
} else {
64-
this.setState(State.AvailableForDownload(update));
65-
}
66-
})
67-
.then(undefined, err => {
68-
this.logService.error(err);
69-
45+
this.requestService.request({ url: this.url }, CancellationToken.None)
46+
.then<IUpdate>(asJson)
47+
.then(update => {
48+
if (!update || !update.url || !update.version || !update.productVersion) {
7049
/* __GDPR__
71-
"update:notAvailable" : {
72-
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
73-
}
50+
"update:notAvailable" : {
51+
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
52+
}
7453
*/
7554
this.telemetryService.publicLog('update:notAvailable', { explicit: !!context });
7655

77-
// only show message when explicitly checking for updates
78-
const message: string | undefined = !!context ? (err.message || err) : undefined;
79-
this.setState(State.Idle(UpdateType.Archive, message));
80-
});
81-
}
82-
}
83-
84-
private checkForSnapUpdate(): void {
85-
// If the application was installed as a snap, updates happen in the
86-
// background automatically, we just need to check to see if an update
87-
// has already happened.
88-
realpath(`${path.dirname(process.env.SNAP!)}/current`, (err, resolvedCurrentSnapPath) => {
89-
if (err) {
90-
this.logService.error('update#checkForSnapUpdate(): Could not get realpath of application.');
91-
return;
92-
}
93-
94-
const currentRevision = path.basename(resolvedCurrentSnapPath);
56+
this.setState(State.Idle(UpdateType.Archive));
57+
} else {
58+
this.setState(State.AvailableForDownload(update));
59+
}
60+
})
61+
.then(undefined, err => {
62+
this.logService.error(err);
63+
64+
/* __GDPR__
65+
"update:notAvailable" : {
66+
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
67+
}
68+
*/
69+
this.telemetryService.publicLog('update:notAvailable', { explicit: !!context });
9570

96-
if (process.env.SNAP_REVISION !== currentRevision) {
97-
// TODO@joao: snap
98-
this.setState(State.Ready({ version: '', productVersion: '' }));
99-
} else {
100-
this.setState(State.Idle(UpdateType.Archive));
101-
}
102-
});
71+
// only show message when explicitly checking for updates
72+
const message: string | undefined = !!context ? (err.message || err) : undefined;
73+
this.setState(State.Idle(UpdateType.Archive, message));
74+
});
10375
}
10476

10577
protected async doDownloadUpdate(state: AvailableForDownload): Promise<void> {
@@ -116,20 +88,5 @@ export class LinuxUpdateService extends AbstractUpdateService {
11688

11789
protected doQuitAndInstall(): void {
11890
this.logService.trace('update#quitAndInstall(): running raw#quitAndInstall()');
119-
120-
const snap = process.env.SNAP;
121-
122-
// TODO@joao what to do?
123-
if (!snap) {
124-
return;
125-
}
126-
127-
// Allow 3 seconds for VS Code to close
128-
spawn('sleep 3 && $SNAP_NAME', {
129-
shell: true,
130-
detached: true,
131-
stdio: 'ignore',
132-
});
133-
13491
}
13592
}

src/vs/platform/update/electron-main/updateService.snap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export class SnapUpdateService extends AbstractUpdateService2 {
190190
this.logService.trace('update#quitAndInstall(): running raw#quitAndInstall()');
191191

192192
// Allow 3 seconds for VS Code to close
193-
spawn('sleep 3 && $SNAP_NAME', {
193+
spawn('sleep 3 && ' + path.basename(process.argv[0]), {
194194
shell: true,
195195
detached: true,
196196
stdio: 'ignore',

0 commit comments

Comments
 (0)