Skip to content

Commit 56af69e

Browse files
authored
Merge pull request #1638 from github/aeisenberg/persist-dbs
Fix bug where dbs are lost on restart
2 parents 09b30fe + d209e52 commit 56af69e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [UNRELEASED]
44

5+
- 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)
56
- 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)
67

78
## 1.7.2 - 14 October 2022

extensions/ql-vscode/src/databases.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,9 @@ export class DatabaseManager extends DisposableObject {
684684
this._onDidChangeDatabaseItem.fire(event);
685685
});
686686

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

@@ -724,6 +726,7 @@ export class DatabaseManager extends DisposableObject {
724726
void this.logger.log(`Error loading database ${database.uri}: ${e}.`);
725727
}
726728
}
729+
await this.updatePersistedDatabaseList();
727730
} catch (e) {
728731
// database list had an unexpected type - nothing to be done?
729732
void showAndLogErrorMessage(`Database list loading failed: ${getErrorMessage(e)}`);
@@ -784,10 +787,14 @@ export class DatabaseManager extends DisposableObject {
784787
private async addDatabaseItem(
785788
progress: ProgressCallback,
786789
token: vscode.CancellationToken,
787-
item: DatabaseItem
790+
item: DatabaseItem,
791+
updatePersistedState = true
788792
) {
789793
this._databaseItems.push(item);
790-
await this.updatePersistedDatabaseList();
794+
795+
if (updatePersistedState) {
796+
await this.updatePersistedDatabaseList();
797+
}
791798

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

0 commit comments

Comments
 (0)