Skip to content

Commit

Permalink
Merge pull request microsoft#65579 from Kedstar99/snapFix
Browse files Browse the repository at this point in the history
Removed snapUpdate.sh and replaced with inline command
  • Loading branch information
joaomoreno authored Jan 28, 2019
2 parents 5d5d386 + 4c02c55 commit eb69d48
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 23 deletions.
5 changes: 1 addition & 4 deletions build/gulpfile.vscode.linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,10 @@ function prepareSnapPackage(arch) {
.pipe(replace('@@VERSION@@', commit.substr(0, 8)))
.pipe(rename('snap/snapcraft.yaml'));

const snapUpdate = gulp.src('resources/linux/snap/snapUpdate.sh', { base: '.' })
.pipe(rename(`usr/share/${product.applicationName}/snapUpdate.sh`));

const electronLaunch = gulp.src('resources/linux/snap/electron-launch', { base: '.' })
.pipe(rename('electron-launch'));

const all = es.merge(desktop, icon, code, snapcraft, electronLaunch, snapUpdate);
const all = es.merge(desktop, icon, code, snapcraft, electronLaunch);

return all.pipe(vfs.dest(destination));
};
Expand Down
3 changes: 0 additions & 3 deletions resources/linux/snap/snapUpdate.sh

This file was deleted.

6 changes: 4 additions & 2 deletions src/vs/platform/update/electron-main/updateService.linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ export class LinuxUpdateService extends AbstractUpdateService {
}

// Allow 3 seconds for VS Code to close
spawn('bash', ['-c', path.join(snap, `usr/share/${product.applicationName}/snapUpdate.sh`)], {
spawn('sleep 3 && $SNAP_NAME', {
shell: true,
detached: true,
stdio: ['ignore', 'ignore', 'ignore']
stdio: 'ignore',
});

}
}
17 changes: 3 additions & 14 deletions src/vs/platform/update/electron-main/updateService.snap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
import { Event, Emitter } from 'vs/base/common/event';
import { timeout } from 'vs/base/common/async';
import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
import product from 'vs/platform/node/product';
import { IUpdateService, State, StateType, AvailableForDownload, UpdateType } from 'vs/platform/update/common/update';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ILogService } from 'vs/platform/log/common/log';
import * as path from 'path';
import { realpath, watch } from 'fs';
import { spawn } from 'child_process';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { stat } from 'vs/base/node/pfs';

abstract class AbstractUpdateService2 implements IUpdateService {

Expand Down Expand Up @@ -137,8 +135,6 @@ export class SnapUpdateService extends AbstractUpdateService2 {

_serviceBrand: any;

private snapUpdatePath: string;

constructor(
private snap: string,
private snapRevision: string,
Expand All @@ -149,8 +145,6 @@ export class SnapUpdateService extends AbstractUpdateService2 {
) {
super(lifecycleService, environmentService, logService);

this.snapUpdatePath = path.join(this.snap, `usr/share/${product.applicationName}/snapUpdate.sh`);

const watcher = watch(path.dirname(this.snap));
const onChange = Event.fromNodeEventEmitter(watcher, 'change', (_, fileName: string) => fileName);
const onCurrentChange = Event.filter(onChange, n => n === 'current');
Expand Down Expand Up @@ -196,19 +190,14 @@ export class SnapUpdateService extends AbstractUpdateService2 {
this.logService.trace('update#quitAndInstall(): running raw#quitAndInstall()');

// Allow 3 seconds for VS Code to close
spawn('bash', ['-c', this.snapUpdatePath], {
spawn('sleep 3 && $SNAP_NAME', {
shell: true,
detached: true,
stdio: ['ignore', 'ignore', 'ignore']
stdio: 'ignore',
});
}

private async isUpdateAvailable(): Promise<boolean> {
try {
await stat(this.snapUpdatePath);
} catch (err) {
return false;
}

const resolvedCurrentSnapPath = await new Promise<string>((c, e) => realpath(`${path.dirname(this.snap)}/current`, (err, r) => err ? e(err) : c(r)));
const currentRevision = path.basename(resolvedCurrentSnapPath);
return this.snapRevision !== currentRevision;
Expand Down

0 comments on commit eb69d48

Please sign in to comment.