remove localStorage workaround in prep for electron 2.0.x update
This commit is contained in:
parent
70f47d4301
commit
fe0177d9a9
1 changed files with 38 additions and 67 deletions
|
@ -61,8 +61,6 @@ import { LogLevelSetterChannel } from 'vs/platform/log/common/logIpc';
|
|||
import { setUnexpectedErrorHandler } from 'vs/base/common/errors';
|
||||
import { ElectronURLListener } from 'vs/platform/url/electron-main/electronUrlListener';
|
||||
import { serve as serveDriver } from 'vs/platform/driver/electron-main/driver';
|
||||
import { join } from 'path';
|
||||
import { exists, unlink, del } from 'vs/base/node/pfs';
|
||||
|
||||
export class CodeApplication {
|
||||
|
||||
|
@ -264,53 +262,49 @@ export class CodeApplication {
|
|||
this.logService.debug(`from: ${this.environmentService.appRoot}`);
|
||||
this.logService.debug('args:', this.environmentService.args);
|
||||
|
||||
// Handle local storage (TODO@Ben remove me after a while)
|
||||
return this.handleLocalStorage().then(() => {
|
||||
// Make sure we associate the program with the app user model id
|
||||
// This will help Windows to associate the running program with
|
||||
// any shortcut that is pinned to the taskbar and prevent showing
|
||||
// two icons in the taskbar for the same app.
|
||||
if (platform.isWindows && product.win32AppUserModelId) {
|
||||
app.setAppUserModelId(product.win32AppUserModelId);
|
||||
}
|
||||
|
||||
// Make sure we associate the program with the app user model id
|
||||
// This will help Windows to associate the running program with
|
||||
// any shortcut that is pinned to the taskbar and prevent showing
|
||||
// two icons in the taskbar for the same app.
|
||||
if (platform.isWindows && product.win32AppUserModelId) {
|
||||
app.setAppUserModelId(product.win32AppUserModelId);
|
||||
// Create Electron IPC Server
|
||||
this.electronIpcServer = new ElectronIPCServer();
|
||||
|
||||
// Resolve unique machine ID
|
||||
this.logService.trace('Resolving machine identifier...');
|
||||
return this.resolveMachineId().then(machineId => {
|
||||
this.logService.trace(`Resolved machine identifier: ${machineId}`);
|
||||
|
||||
// Spawn shared process
|
||||
this.sharedProcess = new SharedProcess(this.environmentService, this.lifecycleService, this.logService, machineId, this.userEnv);
|
||||
this.sharedProcessClient = this.sharedProcess.whenReady().then(() => connect(this.environmentService.sharedIPCHandle, 'main'));
|
||||
|
||||
// Services
|
||||
const appInstantiationService = this.initServices(machineId);
|
||||
|
||||
let promise: TPromise<any> = TPromise.as(null);
|
||||
|
||||
// Create driver
|
||||
if (this.environmentService.driverHandle) {
|
||||
serveDriver(this.electronIpcServer, this.environmentService.driverHandle, appInstantiationService).then(server => {
|
||||
this.logService.info('Driver started at:', this.environmentService.driverHandle);
|
||||
this.toDispose.push(server);
|
||||
});
|
||||
}
|
||||
|
||||
// Create Electron IPC Server
|
||||
this.electronIpcServer = new ElectronIPCServer();
|
||||
return promise.then(() => {
|
||||
// Setup Auth Handler
|
||||
const authHandler = appInstantiationService.createInstance(ProxyAuthHandler);
|
||||
this.toDispose.push(authHandler);
|
||||
|
||||
// Resolve unique machine ID
|
||||
this.logService.trace('Resolving machine identifier...');
|
||||
return this.resolveMachineId().then(machineId => {
|
||||
this.logService.trace(`Resolved machine identifier: ${machineId}`);
|
||||
// Open Windows
|
||||
appInstantiationService.invokeFunction(accessor => this.openFirstWindow(accessor));
|
||||
|
||||
// Spawn shared process
|
||||
this.sharedProcess = new SharedProcess(this.environmentService, this.lifecycleService, this.logService, machineId, this.userEnv);
|
||||
this.sharedProcessClient = this.sharedProcess.whenReady().then(() => connect(this.environmentService.sharedIPCHandle, 'main'));
|
||||
|
||||
// Services
|
||||
const appInstantiationService = this.initServices(machineId);
|
||||
|
||||
let promise: TPromise<any> = TPromise.as(null);
|
||||
|
||||
// Create driver
|
||||
if (this.environmentService.driverHandle) {
|
||||
serveDriver(this.electronIpcServer, this.environmentService.driverHandle, appInstantiationService).then(server => {
|
||||
this.logService.info('Driver started at:', this.environmentService.driverHandle);
|
||||
this.toDispose.push(server);
|
||||
});
|
||||
}
|
||||
|
||||
return promise.then(() => {
|
||||
// Setup Auth Handler
|
||||
const authHandler = appInstantiationService.createInstance(ProxyAuthHandler);
|
||||
this.toDispose.push(authHandler);
|
||||
|
||||
// Open Windows
|
||||
appInstantiationService.invokeFunction(accessor => this.openFirstWindow(accessor));
|
||||
|
||||
// Post Open Windows Tasks
|
||||
appInstantiationService.invokeFunction(accessor => this.afterWindowOpen(accessor));
|
||||
});
|
||||
// Post Open Windows Tasks
|
||||
appInstantiationService.invokeFunction(accessor => this.afterWindowOpen(accessor));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -330,29 +324,6 @@ export class CodeApplication {
|
|||
});
|
||||
}
|
||||
|
||||
private handleLocalStorage(): TPromise<void> {
|
||||
const localStorageBackupFile = join(this.environmentService.userDataPath, 'Local Storage', 'file__0.localstorage.vscbak');
|
||||
const localStorageJournalBackupFile = join(this.environmentService.userDataPath, 'Local Storage', 'file__0.localstorage-journal.vscbak');
|
||||
const localStorageLevelDB = join(this.environmentService.userDataPath, 'Local Storage', 'leveldb');
|
||||
|
||||
// Electron 1.7.12: Delete
|
||||
if (product.quality === 'insider' && process.versions.electron === '1.7.12') {
|
||||
return exists(localStorageBackupFile).then(localStorageBackupFileExists => {
|
||||
return exists(localStorageJournalBackupFile).then(localStorageJournalBackupFileExists => {
|
||||
return exists(localStorageLevelDB).then(localStorageLevelDBExists => {
|
||||
return TPromise.join([
|
||||
localStorageBackupFileExists ? unlink(localStorageBackupFile) : TPromise.as(null),
|
||||
localStorageJournalBackupFileExists ? unlink(localStorageJournalBackupFile) : TPromise.as(null),
|
||||
localStorageLevelDBExists ? del(localStorageLevelDB) : TPromise.as(null)
|
||||
]);
|
||||
});
|
||||
});
|
||||
}).then(() => void 0, () => void 0);
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
private initServices(machineId: string): IInstantiationService {
|
||||
const services = new ServiceCollection();
|
||||
|
||||
|
|
Loading…
Reference in a new issue