Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move keytar to loadSavedConnections VSCODE-450 #574

Merged
merged 4 commits into from
Aug 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/connectionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ export default class ConnectionController {
[]
);

const hasConnectionsThatDidNotMigrateEarlier =
!!globalAndWorkspaceConnections.some(
([, connectionInfo]) => !connectionInfo.storageLocation
);

if (hasConnectionsThatDidNotMigrateEarlier) {
try {
ext.keytarModule =
ext.keytarModule === undefined ? createKeytar() : ext.keytarModule;
addaleax marked this conversation as resolved.
Show resolved Hide resolved
} catch (err) {
// Couldn't load keytar, proceed without storing & loading connections.
}
}

// A list of connection descriptors that we could not migration in the
// current load of connections because of Keytar not being available.
const connectionsThatDidNotMigrate = (
Expand Down Expand Up @@ -296,13 +310,6 @@ export default class ConnectionController {
async _migrateConnectionWithKeytarSecrets(
savedConnectionInfo: StoreConnectionInfoWithConnectionOptions
): Promise<MigratedStoreConnectionInfoWithConnectionOptions | undefined> {
try {
ext.keytarModule =
ext.keytarModule === undefined ? createKeytar() : ext.keytarModule;
} catch (err) {
// Couldn't load keytar, proceed without storing & loading connections.
}

// If the Keytar module is not available, we simply mark the connections
// storage as Keytar and return
if (!ext.keytarModule) {
Expand Down