storage - put migration behind flag

This commit is contained in:
Benjamin Pasero 2018-11-30 17:16:02 +01:00
parent b1f1140ac9
commit b9e55b7047
3 changed files with 21 additions and 13 deletions

View file

@ -30,6 +30,7 @@ const userDataPath = getUserDataPath(args);
// TODO@Ben global storage migration needs to happen very early before app.on("ready") // TODO@Ben global storage migration needs to happen very early before app.on("ready")
// We copy the DB instead of moving it to ensure we are not running into locking issues // We copy the DB instead of moving it to ensure we are not running into locking issues
if (process.env['VSCODE_TEST_STORAGE_MIGRATION']) {
try { try {
const globalStorageHome = path.join(userDataPath, 'User', 'globalStorage', 'temp.vscdb'); const globalStorageHome = path.join(userDataPath, 'User', 'globalStorage', 'temp.vscdb');
const localStorageHome = path.join(userDataPath, 'Local Storage'); const localStorageHome = path.join(userDataPath, 'Local Storage');
@ -41,6 +42,7 @@ try {
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
}
app.setPath('userData', userDataPath); app.setPath('userData', userDataPath);

View file

@ -98,7 +98,7 @@ export class StorageMainService extends Disposable implements IStorageMainServic
} }
private get storagePath(): string { private get storagePath(): string {
if (!!this.environmentService.extensionTestsPath) { if (!!this.environmentService.extensionTestsPath || !process.env['VSCODE_TEST_STORAGE_MIGRATION']) {
return SQLiteStorageDatabase.IN_MEMORY_PATH; // no storage during extension tests! return SQLiteStorageDatabase.IN_MEMORY_PATH; // no storage during extension tests!
} }

View file

@ -535,8 +535,10 @@ export class DelegatingStorageService extends Disposable implements IStorageServ
get(key: string, scope: StorageScope, fallbackValue: string): string; get(key: string, scope: StorageScope, fallbackValue: string): string;
get(key: string, scope: StorageScope, fallbackValue?: string): string | undefined { get(key: string, scope: StorageScope, fallbackValue?: string): string | undefined {
if (!this.useLegacyWorkspaceStorage) { if (!this.useLegacyWorkspaceStorage) {
if (scope === StorageScope.WORKSPACE || process.env['VSCODE_TEST_STORAGE_MIGRATION']) {
return this.storageService.get(key, scope, fallbackValue); return this.storageService.get(key, scope, fallbackValue);
} }
}
return this.storageLegacyService.get(key, this.convertScope(scope), fallbackValue); return this.storageLegacyService.get(key, this.convertScope(scope), fallbackValue);
} }
@ -544,8 +546,10 @@ export class DelegatingStorageService extends Disposable implements IStorageServ
getBoolean(key: string, scope: StorageScope, fallbackValue: boolean): boolean; getBoolean(key: string, scope: StorageScope, fallbackValue: boolean): boolean;
getBoolean(key: string, scope: StorageScope, fallbackValue?: boolean): boolean | undefined { getBoolean(key: string, scope: StorageScope, fallbackValue?: boolean): boolean | undefined {
if (!this.useLegacyWorkspaceStorage) { if (!this.useLegacyWorkspaceStorage) {
if (scope === StorageScope.WORKSPACE || process.env['VSCODE_TEST_STORAGE_MIGRATION']) {
return this.storageService.getBoolean(key, scope, fallbackValue); return this.storageService.getBoolean(key, scope, fallbackValue);
} }
}
return this.storageLegacyService.getBoolean(key, this.convertScope(scope), fallbackValue); return this.storageLegacyService.getBoolean(key, this.convertScope(scope), fallbackValue);
} }
@ -553,8 +557,10 @@ export class DelegatingStorageService extends Disposable implements IStorageServ
getInteger(key: string, scope: StorageScope, fallbackValue: number): number; getInteger(key: string, scope: StorageScope, fallbackValue: number): number;
getInteger(key: string, scope: StorageScope, fallbackValue?: number): number | undefined { getInteger(key: string, scope: StorageScope, fallbackValue?: number): number | undefined {
if (!this.useLegacyWorkspaceStorage) { if (!this.useLegacyWorkspaceStorage) {
if (scope === StorageScope.WORKSPACE || process.env['VSCODE_TEST_STORAGE_MIGRATION']) {
return this.storageService.getInteger(key, scope, fallbackValue); return this.storageService.getInteger(key, scope, fallbackValue);
} }
}
return this.storageLegacyService.getInteger(key, this.convertScope(scope), fallbackValue); return this.storageLegacyService.getInteger(key, this.convertScope(scope), fallbackValue);
} }