提交 0a7c0fd6 编写于 作者: B Benjamin Pasero

debt - lift more environment properties to electron-main

上级 ca4dd67a
......@@ -7,7 +7,6 @@ import { basename, dirname, join } from 'vs/base/common/path';
import { onUnexpectedError } from 'vs/base/common/errors';
import { toDisposable, DisposableStore } from 'vs/base/common/lifecycle';
import { readdir, rimraf, stat } from 'vs/base/node/pfs';
import { INativeEnvironmentService } from 'vs/platform/environment/common/environment';
import product from 'vs/platform/product/common/product';
export class NodeCachedDataCleaner {
......@@ -19,7 +18,7 @@ export class NodeCachedDataCleaner {
private readonly _disposables = new DisposableStore();
constructor(
@INativeEnvironmentService private readonly _environmentService: INativeEnvironmentService
private readonly nodeCachedDataDir: string | undefined
) {
this._manageCachedDataSoon();
}
......@@ -32,14 +31,14 @@ export class NodeCachedDataCleaner {
// Cached data is stored as user data and we run a cleanup task everytime
// the editor starts. The strategy is to delete all files that are older than
// 3 months (1 week respectively)
if (!this._environmentService.nodeCachedDataDir) {
if (!this.nodeCachedDataDir) {
return;
}
// The folder which contains folders of cached data. Each of these folder is per
// version
const nodeCachedDataRootDir = dirname(this._environmentService.nodeCachedDataDir);
const nodeCachedDataCurrent = basename(this._environmentService.nodeCachedDataDir);
const nodeCachedDataRootDir = dirname(this.nodeCachedDataDir);
const nodeCachedDataCurrent = basename(this.nodeCachedDataDir);
let handle: NodeJS.Timeout | undefined = setTimeout(() => {
handle = undefined;
......
......@@ -84,6 +84,7 @@ interface ISharedProcessInitData {
sharedIPCHandle: string;
args: NativeParsedArgs;
logLevel: LogLevel;
nodeCachedDataDir?: string;
backupWorkspacesPath: string;
}
......@@ -261,7 +262,7 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
(localizationsService as LocalizationsService).update();
// cache clean ups
disposables.add(combinedDisposable(
instantiationService2.createInstance(NodeCachedDataCleaner),
new NodeCachedDataCleaner(initData.nodeCachedDataDir),
instantiationService2.createInstance(LanguagePackCachedDataCleaner),
instantiationService2.createInstance(StorageDataCleaner, initData.backupWorkspacesPath),
instantiationService2.createInstance(LogsDataCleaner),
......
......@@ -116,7 +116,8 @@ export class SharedProcess implements ISharedProcess {
sharedIPCHandle: this.environmentService.sharedIPCHandle,
args: this.environmentService.args,
logLevel: this.logService.getLevel(),
backupWorkspacesPath: this.environmentService.backupWorkspacesPath
backupWorkspacesPath: this.environmentService.backupWorkspacesPath,
nodeCachedDataDir: this.environmentService.nodeCachedDataDir
});
// signal exit to shared process when we get disposed
......
......@@ -44,7 +44,6 @@ export interface IEnvironmentService {
// --- data paths
untitledWorkspacesHome: URI;
globalStorageHome: URI;
workspaceStorageHome: URI;
......@@ -69,7 +68,6 @@ export interface IEnvironmentService {
// --- telemetry
disableTelemetry: boolean;
telemetryLogResource: URI;
serviceMachineIdResource: URI;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
......@@ -100,11 +98,9 @@ export interface INativeEnvironmentService extends IEnvironmentService {
tmpDir: URI;
userDataPath: string;
machineSettingsResource: URI;
nodeCachedDataDir?: string;
installSourcePath: string;
// --- IPC Handles
mainIPCHandle: string;
sharedIPCHandle: string;
// --- Extensions
......@@ -114,11 +110,6 @@ export interface INativeEnvironmentService extends IEnvironmentService {
// --- Smoke test support
driverHandle?: string;
driverVerbose: boolean;
// --- Misc. config
disableUpdates: boolean;
sandbox: boolean;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NOTE: KEEP THIS INTERFACE AS SMALL AS POSSIBLE. AS SUCH:
......
......@@ -7,7 +7,7 @@ import { join } from 'vs/base/common/path';
import { memoize } from 'vs/base/common/decorators';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { INativeEnvironmentService } from 'vs/platform/environment/common/environment';
import { NativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
import { getIPCHandle, NativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
export const IEnvironmentMainService = createDecorator<IEnvironmentMainService>('environmentMainService');
......@@ -16,8 +16,21 @@ export const IEnvironmentMainService = createDecorator<IEnvironmentMainService>(
* environments.
*/
export interface IEnvironmentMainService extends INativeEnvironmentService {
// --- backup paths
backupHome: string;
backupWorkspacesPath: string;
// --- V8 script cache path
nodeCachedDataDir?: string;
// --- IPC
mainIPCHandle: string;
// --- config
sandbox: boolean;
driverVerbose: boolean;
disableUpdates: boolean;
}
export class EnvironmentMainService extends NativeEnvironmentService {
......@@ -27,4 +40,19 @@ export class EnvironmentMainService extends NativeEnvironmentService {
@memoize
get backupWorkspacesPath(): string { return join(this.backupHome, 'workspaces.json'); }
@memoize
get mainIPCHandle(): string { return getIPCHandle(this.userDataPath, 'main'); }
@memoize
get sandbox(): boolean { return !!this._args['__sandbox']; }
@memoize
get driverVerbose(): boolean { return !!this._args['driver-verbose']; }
@memoize
get disableUpdates(): boolean { return !!this._args['disable-updates']; }
@memoize
get nodeCachedDataDir(): string | undefined { return process.env['VSCODE_NODE_CACHED_DATA_DIR'] || undefined; }
}
......@@ -189,32 +189,22 @@ export class NativeEnvironmentService implements INativeEnvironmentService {
get verbose(): boolean { return !!this._args.verbose; }
get logLevel(): string | undefined { return this._args.log; }
@memoize
get mainIPCHandle(): string { return getIPCHandle(this.userDataPath, 'main'); }
@memoize
get sharedIPCHandle(): string { return getIPCHandle(this.userDataPath, 'shared'); }
@memoize
get nodeCachedDataDir(): string | undefined { return process.env['VSCODE_NODE_CACHED_DATA_DIR'] || undefined; }
@memoize
get serviceMachineIdResource(): URI { return resources.joinPath(URI.file(this.userDataPath), 'machineid'); }
get disableUpdates(): boolean { return !!this._args['disable-updates']; }
get crashReporterId(): string | undefined { return this._args['crash-reporter-id']; }
get crashReporterDirectory(): string | undefined { return this._args['crash-reporter-directory']; }
get driverHandle(): string | undefined { return this._args['driver']; }
get driverVerbose(): boolean { return !!this._args['driver-verbose']; }
@memoize
get telemetryLogResource(): URI { return URI.file(path.join(this.logsPath, 'telemetry.log')); }
get disableTelemetry(): boolean { return !!this._args['disable-telemetry']; }
get sandbox(): boolean { return !!this._args['__sandbox']; }
constructor(private _args: NativeParsedArgs) {
constructor(protected _args: NativeParsedArgs) {
if (!process.env['VSCODE_LOGS']) {
const key = toLocalISOString(new Date()).replace(/-|:|\.\d+Z$/g, '');
process.env['VSCODE_LOGS'] = path.join(this.userDataPath, 'logs', key);
......@@ -261,7 +251,7 @@ function getWin32IPCHandle(userDataPath: string, type: string): string {
return `\\\\.\\pipe\\${scope}-${product.version}-${type}-sock`;
}
function getIPCHandle(userDataPath: string, type: string): string {
export function getIPCHandle(userDataPath: string, type: string): string {
if (isWindows) {
return getWin32IPCHandle(userDataPath, type);
}
......
......@@ -126,7 +126,6 @@ export class SimpleNativeWorkbenchEnvironmentService implements INativeWorkbench
installSourcePath: string = undefined!;
mainIPCHandle: string = undefined!;
sharedIPCHandle: string = undefined!;
extensionsPath?: string | undefined;
......@@ -134,15 +133,12 @@ export class SimpleNativeWorkbenchEnvironmentService implements INativeWorkbench
builtinExtensionsPath: string = undefined!;
driverHandle?: string | undefined;
driverVerbose = false;
crashReporterDirectory?: string | undefined;
crashReporterId?: string | undefined;
nodeCachedDataDir?: string | undefined;
disableUpdates = false;
sandbox = true;
verbose = false;
isBuilt = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册