提交 b36c0e19 编写于 作者: J Johannes Rieken

move globalStorageHome, workspaceStorageHome to shared env-service,...

move globalStorageHome, workspaceStorageHome to shared env-service, https://github.com/microsoft/vscode/issues/101857
上级 793c1b28
......@@ -35,7 +35,7 @@ export class StorageDataCleaner extends Disposable {
const emptyWorkspaces = workspaces.emptyWorkspaceInfos.map(info => info.backupFolder);
// Read all workspace storage folders that exist
return readdir(this.environmentService.workspaceStorageHome).then(storageFolders => {
return readdir(this.environmentService.workspaceStorageHome.fsPath).then(storageFolders => {
const deletes: Promise<void>[] = [];
storageFolders.forEach(storageFolder => {
......@@ -44,7 +44,7 @@ export class StorageDataCleaner extends Disposable {
}
if (emptyWorkspaces.indexOf(storageFolder) === -1) {
deletes.push(rimraf(join(this.environmentService.workspaceStorageHome, storageFolder)));
deletes.push(rimraf(join(this.environmentService.workspaceStorageHome.fsPath, storageFolder)));
}
});
......
......@@ -178,8 +178,8 @@ class CodeMain {
environmentService.extensionsPath,
environmentService.nodeCachedDataDir,
environmentService.logsPath,
environmentService.globalStorageHome,
environmentService.workspaceStorageHome,
environmentService.globalStorageHome.fsPath,
environmentService.workspaceStorageHome.fsPath,
environmentService.backupHome.fsPath
].map((path): undefined | Promise<void> => path ? mkdirp(path) : undefined));
......
......@@ -40,6 +40,9 @@ export interface IEnvironmentService {
backupHome: URI;
untitledWorkspacesHome: URI;
globalStorageHome: URI;
workspaceStorageHome: URI;
// --- settings sync
userDataSyncLogResource: URI;
userDataSyncHome: URI;
......
......@@ -39,9 +39,6 @@ export interface INativeEnvironmentService extends IEnvironmentService {
extensionsDownloadPath: string;
builtinExtensionsPath: string;
globalStorageHome: string;
workspaceStorageHome: string;
driverHandle?: string;
driverVerbose: boolean;
......@@ -102,10 +99,10 @@ export class EnvironmentService implements INativeEnvironmentService {
get machineSettingsResource(): URI { return resources.joinPath(URI.file(path.join(this.userDataPath, 'Machine')), 'settings.json'); }
@memoize
get globalStorageHome(): string { return path.join(this.appSettingsHome.fsPath, 'globalStorage'); }
get globalStorageHome(): URI { return URI.joinPath(this.appSettingsHome, 'globalStorage'); }
@memoize
get workspaceStorageHome(): string { return path.join(this.appSettingsHome.fsPath, 'workspaceStorage'); }
get workspaceStorageHome(): URI { return URI.joinPath(this.appSettingsHome, 'workspaceStorage'); }
@memoize
get keybindingsResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'keybindings.json'); }
......
......@@ -130,6 +130,6 @@ export class ExtensionsLifecycle extends Disposable {
}
private getExtensionStoragePath(extension: ILocalExtension): string {
return join(this.environmentService.globalStorageHome, extension.identifier.id.toLowerCase());
return join(this.environmentService.globalStorageHome.fsPath, extension.identifier.id.toLowerCase());
}
}
......@@ -117,7 +117,7 @@ export class StorageMainService extends Disposable implements IStorageMainServic
return SQLiteStorageDatabase.IN_MEMORY_PATH; // no storage during extension tests!
}
return join(this.environmentService.globalStorageHome, StorageMainService.STORAGE_NAME);
return join(this.environmentService.globalStorageHome.fsPath, StorageMainService.STORAGE_NAME);
}
private createLogginOptions(): ISQLiteStorageDatabaseLoggingOptions {
......
......@@ -143,7 +143,7 @@ export class NativeStorageService extends Disposable implements IStorageService
}
private getWorkspaceStorageFolderPath(payload: IWorkspaceInitializationPayload): string {
return join(this.environmentService.workspaceStorageHome, payload.id); // workspace home + workspace id;
return join(this.environmentService.workspaceStorageHome.fsPath, payload.id); // workspace home + workspace id;
}
private async prepareWorkspaceStorageFolder(payload: IWorkspaceInitializationPayload): Promise<{ path: string, wasCreated: boolean }> {
......@@ -257,7 +257,7 @@ export class NativeStorageService extends Disposable implements IStorageService
return logStorage(
this.globalStorage.items,
this.workspaceStorage ? this.workspaceStorage.items : new Map<string, string>(), // Shared process storage does not has workspace storage
this.environmentService.globalStorageHome,
this.environmentService.globalStorageHome.fsPath,
this.workspaceStoragePath || '');
}
......
......@@ -14,6 +14,7 @@ import { NullLogService } from 'vs/platform/log/common/log';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { InMemoryStorageDatabase } from 'vs/base/parts/storage/common/storage';
import { URI } from 'vs/base/common/uri';
suite('StorageService', () => {
......@@ -85,11 +86,11 @@ suite('StorageService', () => {
test('Migrate Data', async () => {
class StorageTestEnvironmentService extends EnvironmentService {
constructor(private workspaceStorageFolderPath: string, private _extensionsPath: string) {
constructor(private workspaceStorageFolderPath: URI, private _extensionsPath: string) {
super(parseArgs(process.argv, OPTIONS), process.execPath);
}
get workspaceStorageHome(): string {
get workspaceStorageHome(): URI {
return this.workspaceStorageFolderPath;
}
......@@ -101,7 +102,7 @@ suite('StorageService', () => {
const storageDir = uniqueStorageDir();
await mkdirp(storageDir);
const storage = new NativeStorageService(new InMemoryStorageDatabase(), new NullLogService(), new StorageTestEnvironmentService(storageDir, storageDir));
const storage = new NativeStorageService(new InMemoryStorageDatabase(), new NullLogService(), new StorageTestEnvironmentService(URI.file(storageDir), storageDir));
await storage.initialize({ id: String(Date.now()) });
storage.store('bar', 'foo', StorageScope.WORKSPACE);
......
......@@ -217,7 +217,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
rimrafSync(dirname(configPath));
// Mark Workspace Storage to be deleted
const workspaceStoragePath = join(this.environmentService.workspaceStorageHome, workspace.id);
const workspaceStoragePath = join(this.environmentService.workspaceStorageHome.fsPath, workspace.id);
if (existsSync(workspaceStoragePath)) {
writeFileSync(join(workspaceStoragePath, 'obsolete'), '');
}
......
......@@ -133,6 +133,12 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
@memoize
get snippetsHome(): URI { return joinPath(this.userRoamingDataHome, 'snippets'); }
@memoize
get globalStorageHome(): URI { return URI.joinPath(this.userRoamingDataHome, 'globalStorage'); }
@memoize
get workspaceStorageHome(): URI { return URI.joinPath(this.userRoamingDataHome, 'workspaceStorage'); }
/*
* In Web every workspace can potentially have scoped user-data and/or extensions and if Sync state is shared then it can make
* Sync error prone - say removing extensions from another workspace. Hence scope Sync state per workspace.
......
......@@ -436,7 +436,7 @@ export class LocalProcessExtensionHost implements IExtensionHost {
appLanguage: platform.language,
extensionDevelopmentLocationURI: this._environmentService.extensionDevelopmentLocationURI,
extensionTestsLocationURI: this._environmentService.extensionTestsLocationURI,
globalStorageHome: URI.file(this._environmentService.globalStorageHome),
globalStorageHome: this._environmentService.globalStorageHome,
webviewResourceRoot: this._environmentService.webviewResourceRoot,
webviewCspSource: this._environmentService.webviewCspSource,
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册