@@ -45,7 +45,6 @@ export class NativeStorageService extends AbstractStorageService {
45
45
46
46
private createApplicationStorage ( ) : IStorage {
47
47
const storageDataBaseClient = new StorageDatabaseChannelClient ( this . mainProcessService . getChannel ( 'storage' ) , this . userDataProfilesService , undefined ) ;
48
-
49
48
const applicationStorage = new Storage ( storageDataBaseClient . applicationStorage ) ;
50
49
51
50
this . _register ( applicationStorage . onDidChangeStorage ( key => this . emitDidChangeValue ( StorageScope . APPLICATION , key ) ) ) ;
@@ -54,9 +53,20 @@ export class NativeStorageService extends AbstractStorageService {
54
53
}
55
54
56
55
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 ) {
58
59
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
+ }
60
70
61
71
this . _register ( globalStorage . onDidChangeStorage ( key => this . emitDidChangeValue ( StorageScope . GLOBAL , key ) ) ) ;
62
72
0 commit comments