From d57255152c77fb46b6680fdd51e2bb9b8c79057f Mon Sep 17 00:00:00 2001 From: Andrew Eisenberg Date: Sun, 17 Mar 2024 11:25:05 -0700 Subject: [PATCH] Safely check for out of date databases When checking to re-import test databases, if the target database is missing or otherwise unavailable, avoid the check and just continue. This avoids a bug where a user would delete a test database and there would be an error when trying to run a query. --- .../src/databases/local-databases/database-manager.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/extensions/ql-vscode/src/databases/local-databases/database-manager.ts b/extensions/ql-vscode/src/databases/local-databases/database-manager.ts index a1a7dc28b..13e975a87 100644 --- a/extensions/ql-vscode/src/databases/local-databases/database-manager.ts +++ b/extensions/ql-vscode/src/databases/local-databases/database-manager.ts @@ -227,8 +227,16 @@ export class DatabaseManager extends DisposableObject { "codeql-database.yml", ); + let originStat; + try { + originStat = await stat(originDbYml); + } catch (e) { + // if there is an error here, assume that the origin database + // is no longer available. Safely ignore and do not try to re-import. + return false; + } + try { - const originStat = await stat(originDbYml); const importedStat = await stat(importedDbYml); return originStat.mtimeMs > importedStat.mtimeMs; } catch (e) {