From 0fe64c98b10f1b98947c629e1df50086493fa2e5 Mon Sep 17 00:00:00 2001 From: Andrew Eisenberg Date: Tue, 9 Feb 2021 09:54:19 -0800 Subject: [PATCH] Avoid displaying irrelevant error Problem was misplaced parens. We were not waiting for the call to `pathExists` to complete before making the call to `stat` the directory. When the directory does not exist, then `stat` throws an error. --- extensions/ql-vscode/CHANGELOG.md | 2 ++ extensions/ql-vscode/src/databases-ui.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index 9c351a9e787..69c6d0d0d66 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -2,6 +2,8 @@ ## [UNRELEASED] +- Avoid displaying an error when removing orphaned databases and the storage folder does not exist. [#748](https://github.com/github/vscode-codeql/pull/748) + ## 1.4.2 - 2 February 2021 - Add a status bar item for the CodeQL CLI to show the current version. [#741](https://github.com/github/vscode-codeql/pull/741) diff --git a/extensions/ql-vscode/src/databases-ui.ts b/extensions/ql-vscode/src/databases-ui.ts index 1b1a7b79d7e..94393629d86 100644 --- a/extensions/ql-vscode/src/databases-ui.ts +++ b/extensions/ql-vscode/src/databases-ui.ts @@ -379,8 +379,8 @@ export class DatabaseUI extends DisposableObject { let dbDirs = undefined; if ( - !(await fs.pathExists(this.storagePath) || - !(await fs.stat(this.storagePath)).isDirectory()) + !(await fs.pathExists(this.storagePath)) || + !(await fs.stat(this.storagePath)).isDirectory() ) { logger.log('Missing or invalid storage directory. Not trying to remove orphaned databases.'); return;