From b9e55b7047027a2f79ca3eb67c85a388244f39ff Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Fri, 30 Nov 2018 17:16:02 +0100 Subject: [PATCH] storage - put migration behind flag --- src/main.js | 20 ++++++++++--------- .../storage/node/storageMainService.ts | 2 +- .../platform/storage/node/storageService.ts | 12 ++++++++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main.js b/src/main.js index a4c18d653c4..44658a3172f 100644 --- a/src/main.js +++ b/src/main.js @@ -30,16 +30,18 @@ const userDataPath = getUserDataPath(args); // 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 -try { - const globalStorageHome = path.join(userDataPath, 'User', 'globalStorage', 'temp.vscdb'); - const localStorageHome = path.join(userDataPath, 'Local Storage'); - const localStorageDB = path.join(localStorageHome, 'file__0.localstorage'); - const localStorageDBBackup = path.join(localStorageHome, 'file__0.localstorage.vscmig'); - if (!fs.existsSync(globalStorageHome) && fs.existsSync(localStorageDB)) { - fs.copyFileSync(localStorageDB, localStorageDBBackup); +if (process.env['VSCODE_TEST_STORAGE_MIGRATION']) { + try { + const globalStorageHome = path.join(userDataPath, 'User', 'globalStorage', 'temp.vscdb'); + const localStorageHome = path.join(userDataPath, 'Local Storage'); + const localStorageDB = path.join(localStorageHome, 'file__0.localstorage'); + const localStorageDBBackup = path.join(localStorageHome, 'file__0.localstorage.vscmig'); + if (!fs.existsSync(globalStorageHome) && fs.existsSync(localStorageDB)) { + fs.copyFileSync(localStorageDB, localStorageDBBackup); + } + } catch (error) { + console.error(error); } -} catch (error) { - console.error(error); } app.setPath('userData', userDataPath); diff --git a/src/vs/platform/storage/node/storageMainService.ts b/src/vs/platform/storage/node/storageMainService.ts index d81742e026d..6833065a11e 100644 --- a/src/vs/platform/storage/node/storageMainService.ts +++ b/src/vs/platform/storage/node/storageMainService.ts @@ -98,7 +98,7 @@ export class StorageMainService extends Disposable implements IStorageMainServic } 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! } diff --git a/src/vs/platform/storage/node/storageService.ts b/src/vs/platform/storage/node/storageService.ts index 008f0e19f66..9f477db7b87 100644 --- a/src/vs/platform/storage/node/storageService.ts +++ b/src/vs/platform/storage/node/storageService.ts @@ -535,7 +535,9 @@ export class DelegatingStorageService extends Disposable implements IStorageServ get(key: string, scope: StorageScope, fallbackValue: string): string; get(key: string, scope: StorageScope, fallbackValue?: string): string | undefined { if (!this.useLegacyWorkspaceStorage) { - return this.storageService.get(key, scope, fallbackValue); + if (scope === StorageScope.WORKSPACE || process.env['VSCODE_TEST_STORAGE_MIGRATION']) { + return this.storageService.get(key, scope, fallbackValue); + } } return this.storageLegacyService.get(key, this.convertScope(scope), fallbackValue); @@ -544,7 +546,9 @@ export class DelegatingStorageService extends Disposable implements IStorageServ getBoolean(key: string, scope: StorageScope, fallbackValue: boolean): boolean; getBoolean(key: string, scope: StorageScope, fallbackValue?: boolean): boolean | undefined { if (!this.useLegacyWorkspaceStorage) { - return this.storageService.getBoolean(key, scope, fallbackValue); + if (scope === StorageScope.WORKSPACE || process.env['VSCODE_TEST_STORAGE_MIGRATION']) { + return this.storageService.getBoolean(key, scope, fallbackValue); + } } return this.storageLegacyService.getBoolean(key, this.convertScope(scope), fallbackValue); @@ -553,7 +557,9 @@ export class DelegatingStorageService extends Disposable implements IStorageServ getInteger(key: string, scope: StorageScope, fallbackValue: number): number; getInteger(key: string, scope: StorageScope, fallbackValue?: number): number | undefined { if (!this.useLegacyWorkspaceStorage) { - return this.storageService.getInteger(key, scope, fallbackValue); + if (scope === StorageScope.WORKSPACE || process.env['VSCODE_TEST_STORAGE_MIGRATION']) { + return this.storageService.getInteger(key, scope, fallbackValue); + } } return this.storageLegacyService.getInteger(key, this.convertScope(scope), fallbackValue);