Skip to content

Commit

Permalink
Merge pull request #1638 from github/aeisenberg/persist-dbs
Browse files Browse the repository at this point in the history
Fix bug where dbs are lost on restart
  • Loading branch information
aeisenberg authored Oct 25, 2022
2 parents 09b30fe + d209e52 commit 56af69e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [UNRELEASED]

- Fix a bug where databases may be lost if VS Code is restarted while the extension is being started up. [#1638](https://github.com/github/vscode-codeql/pull/1638)
- Add commands for navigating up, down, left, or right in the result viewer. Previously there were only commands for moving up and down the currently-selected path. We suggest binding keyboard shortcuts to these commands, for navigating the result viewer using the keyboard. [#1568](https://github.com/github/vscode-codeql/pull/1568)

## 1.7.2 - 14 October 2022
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

0 comments on commit 56af69e

Please sign in to comment.