Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [UNRELEASED]

- Fix a bug where persisted databases may be lost if VS code is restarted while databases are being initialized. [#1638](https://github.com/github/vscode-codeql/pull/1638)
Comment thread
aeisenberg marked this conversation as resolved.
Outdated

## 1.7.2 - 14 October 2022

- Fix a bug where results created in older versions were thought to be unsuccessful. [#1605](https://github.com/github/vscode-codeql/pull/1605)
Expand Down
13 changes: 10 additions & 3 deletions extensions/ql-vscode/src/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,9 @@ export class DatabaseManager extends DisposableObject {
this._onDidChangeDatabaseItem.fire(event);
});

await this.addDatabaseItem(progress, token, item);
// Avoid persisting the database state after adding since that should happen only after
// all databases have been added.
await this.addDatabaseItem(progress, token, item, false);
return item;
}

Expand Down Expand Up @@ -724,6 +726,7 @@ export class DatabaseManager extends DisposableObject {
void this.logger.log(`Error loading database ${database.uri}: ${e}.`);
}
}
await this.updatePersistedDatabaseList();
} catch (e) {
// database list had an unexpected type - nothing to be done?
void showAndLogErrorMessage(`Database list loading failed: ${getErrorMessage(e)}`);
Expand Down Expand Up @@ -784,10 +787,14 @@ export class DatabaseManager extends DisposableObject {
private async addDatabaseItem(
progress: ProgressCallback,
token: vscode.CancellationToken,
item: DatabaseItem
item: DatabaseItem,
updatePersistedState = true
) {
this._databaseItems.push(item);
await this.updatePersistedDatabaseList();

if (updatePersistedState) {
await this.updatePersistedDatabaseList();
}

// Add this database item to the allow-list
// Database items reconstituted from persisted state
Expand Down