Skip to content

Commit 093d341

Browse files
chore: move keytar to loadSavedConnections VSCODE-450 (#574)
* chore: move keytar to loadSavedConnections * chore: Only load keytar if connections were not migrated earlier * chore: only load keytar if at least one connection needs to be migrated --------- Co-authored-by: Alena Khineika <[email protected]>
1 parent 3f52d05 commit 093d341

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/connectionController.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,20 @@ export default class ConnectionController {
170170
[]
171171
);
172172

173+
const hasConnectionsThatDidNotMigrateEarlier =
174+
!!globalAndWorkspaceConnections.some(
175+
([, connectionInfo]) => !connectionInfo.storageLocation
176+
);
177+
178+
if (hasConnectionsThatDidNotMigrateEarlier) {
179+
try {
180+
ext.keytarModule =
181+
ext.keytarModule === undefined ? createKeytar() : ext.keytarModule;
182+
} catch (err) {
183+
// Couldn't load keytar, proceed without storing & loading connections.
184+
}
185+
}
186+
173187
// A list of connection descriptors that we could not migration in the
174188
// current load of connections because of Keytar not being available.
175189
const connectionsThatDidNotMigrate = (
@@ -296,13 +310,6 @@ export default class ConnectionController {
296310
async _migrateConnectionWithKeytarSecrets(
297311
savedConnectionInfo: StoreConnectionInfoWithConnectionOptions
298312
): 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-
306313
// If the Keytar module is not available, we simply mark the connections
307314
// storage as Keytar and return
308315
if (!ext.keytarModule) {

0 commit comments

Comments
 (0)