Skip to content

Commit a4906e2

Browse files
committed
dont create storage in default profile twice
1 parent efb5563 commit a4906e2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/vs/platform/storage/electron-sandbox/storageService.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export class NativeStorageService extends AbstractStorageService {
4545

4646
private createApplicationStorage(): IStorage {
4747
const storageDataBaseClient = new StorageDatabaseChannelClient(this.mainProcessService.getChannel('storage'), this.userDataProfilesService, undefined);
48-
4948
const applicationStorage = new Storage(storageDataBaseClient.applicationStorage);
5049

5150
this._register(applicationStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.APPLICATION, key)));
@@ -54,9 +53,20 @@ export class NativeStorageService extends AbstractStorageService {
5453
}
5554

5655
private createGlobalStorage(): IStorage {
57-
const storageDataBaseClient = new StorageDatabaseChannelClient(this.mainProcessService.getChannel('storage'), this.userDataProfilesService, undefined);
56+
let globalStorage: IStorage;
57+
58+
if (this.userDataProfilesService.currentProfile.isDefault) {
5859

59-
const globalStorage = new Storage(storageDataBaseClient.globalStorage);
60+
// If we are in default profile, the global storage is
61+
// actually the same as application storage. As such we
62+
// avoid creating the storage library a second time on
63+
// the same DB.
64+
65+
globalStorage = this.applicationStorage;
66+
} else {
67+
const storageDataBaseClient = new StorageDatabaseChannelClient(this.mainProcessService.getChannel('storage'), this.userDataProfilesService, undefined);
68+
globalStorage = new Storage(storageDataBaseClient.globalStorage);
69+
}
6070

6171
this._register(globalStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.GLOBAL, key)));
6272

0 commit comments

Comments
 (0)