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.
This commit is contained in:
Andrew Eisenberg 2024-03-17 11:25:05 -07:00
Родитель 752ec04400
Коммит d57255152c
1 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -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) {