Log if a database metadata file could not be found
This is a key cause of not being able to produce interpreted results, so logging it helps us debug a lack of interpreted results. Also make the database metadata check async
This commit is contained in:
@@ -227,9 +227,9 @@ export interface DatabaseItem {
|
||||
resolveSourceFile(file: string | undefined): vscode.Uri;
|
||||
|
||||
/**
|
||||
* Holds if the database item has a `.dbinfo` file.
|
||||
* Holds if the database item has a `.dbinfo` or `codeql-database.yml` file.
|
||||
*/
|
||||
hasDbInfo(): boolean;
|
||||
hasMetadataFile(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Returns `sourceLocationPrefix` of exported database.
|
||||
@@ -359,9 +359,11 @@ class DatabaseItemImpl implements DatabaseItem {
|
||||
/**
|
||||
* Holds if the database item refers to an exported snapshot
|
||||
*/
|
||||
public hasDbInfo(): boolean {
|
||||
return fs.existsSync(path.join(this.databaseUri.fsPath, '.dbinfo'))
|
||||
|| fs.existsSync(path.join(this.databaseUri.fsPath, 'codeql-database.yml'));;
|
||||
public async hasMetadataFile(): Promise<boolean> {
|
||||
return (await Promise.all([
|
||||
fs.pathExists(path.join(this.databaseUri.fsPath, '.dbinfo')),
|
||||
fs.pathExists(path.join(this.databaseUri.fsPath, 'codeql-database.yml'))
|
||||
])).some(x => x);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -150,8 +150,12 @@ export class QueryInfo {
|
||||
/**
|
||||
* Holds if this query should produce interpreted results.
|
||||
*/
|
||||
hasInterpretedResults(): boolean {
|
||||
return this.dbItem.hasDbInfo();
|
||||
async hasInterpretedResults(): Promise<boolean> {
|
||||
const hasMetadataFile = await this.dbItem.hasMetadataFile();
|
||||
if (!hasMetadataFile) {
|
||||
logger.log("Cannot produce interpreted results since the database does not have a .dbinfo or codeql-database.yml file.");
|
||||
}
|
||||
return hasMetadataFile;
|
||||
}
|
||||
|
||||
async updateSortState(server: cli.CodeQLCliServer, resultSetName: string, sortState: SortState | undefined): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user