File tree Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import ConnectionString from 'mongodb-connection-string-url';
13
13
import { EventEmitter } from 'events' ;
14
14
import type { MongoClientOptions } from 'mongodb' ;
15
15
import { v4 as uuidv4 } from 'uuid' ;
16
-
16
+ import { createKeytar } from './utils/keytar' ;
17
17
import { CONNECTION_STATUS } from './views/webview-app/extension-app-message-constants' ;
18
18
import { createLogger } from './logging' ;
19
19
import { ext } from './extensionConstants' ;
@@ -296,6 +296,13 @@ export default class ConnectionController {
296
296
async _migrateConnectionWithKeytarSecrets (
297
297
savedConnectionInfo : StoreConnectionInfoWithConnectionOptions
298
298
) : Promise < MigratedStoreConnectionInfoWithConnectionOptions | undefined > {
299
+ try {
300
+ ext . keytarModule =
301
+ ext . keytarModule === undefined ? createKeytar ( ) : ext . keytarModule ;
302
+ } catch ( err ) {
303
+ // Couldn't load keytar, proceed without storing & loading connections.
304
+ }
305
+
299
306
// If the Keytar module is not available, we simply mark the connections
300
307
// storage as Keytar and return
301
308
if ( ! ext . keytarModule ) {
Original file line number Diff line number Diff line change 3
3
import * as vscode from 'vscode' ;
4
4
5
5
import { ext } from './extensionConstants' ;
6
- import { createKeytar } from './utils/keytar' ;
7
6
import { createLogger } from './logging' ;
8
7
// eslint-disable-next-line @typescript-eslint/no-var-requires
9
8
const { version } = require ( '../package.json' ) ;
@@ -30,14 +29,6 @@ export async function activate(
30
29
context : vscode . ExtensionContext
31
30
) : Promise < void > {
32
31
ext . context = context ;
33
- let hasKeytar = false ;
34
-
35
- try {
36
- ext . keytarModule = createKeytar ( ) ;
37
- hasKeytar = true ;
38
- } catch ( err ) {
39
- // Couldn't load keytar, proceed without storing & loading connections.
40
- }
41
32
42
33
const defaultConnectionSavingLocation = vscode . workspace
43
34
. getConfiguration ( 'mdb.connectionSaving' )
@@ -53,7 +44,6 @@ export async function activate(
53
44
workspaceStoragePath : context . storageUri ?. path ,
54
45
globalStoragePath : context . globalStorageUri . path ,
55
46
defaultConnectionSavingLocation,
56
- hasKeytar,
57
47
buildInfo : {
58
48
nodeVersion : process . version ,
59
49
runtimePlatform : process . platform ,
You can’t perform that action at this time.
0 commit comments