Fix showing of raw evaluator log for cancelled items

This will ensure that when "Show Evaluator Log (Raw JSON)" is used on a
cancelled query history item, we will still show it if it exists. This
changes the error messages on other cases to be more specific.
This commit is contained in:
Koen Vlaswinkel 2023-10-18 16:15:56 +02:00
Родитель 9928c338e9
Коммит 226274cb4e
1 изменённых файлов: 23 добавлений и 41 удалений

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

@ -702,24 +702,6 @@ export class QueryHistoryManager extends DisposableObject {
} }
} }
async getQueryHistoryItemDirectory(
queryHistoryItem: QueryHistoryInfo,
): Promise<string> {
if (queryHistoryItem.t === "local") {
if (queryHistoryItem.completedQuery) {
return queryHistoryItem.completedQuery.query.querySaveDir;
}
} else if (queryHistoryItem.t === "variant-analysis") {
return this.variantAnalysisManager.getVariantAnalysisStorageLocation(
queryHistoryItem.variantAnalysis.id,
);
} else {
assertNever(queryHistoryItem);
}
throw new Error("Unable to get query directory");
}
async handleOpenQueryDirectory(item: QueryHistoryInfo) { async handleOpenQueryDirectory(item: QueryHistoryInfo) {
let externalFilePath: string | undefined; let externalFilePath: string | undefined;
if (item.t === "local") { if (item.t === "local") {
@ -781,18 +763,20 @@ export class QueryHistoryManager extends DisposableObject {
); );
} }
private warnInProgressEvalLogSummary() { private async warnNoEvalLogSummary(item: LocalQueryInfo) {
void showAndLogWarningMessage( const evalLogLocation =
this.app.logger, item.evalLogLocation ?? item.initialInfo.outputDir?.evalLogPath;
'The evaluator log summary is still being generated for this run. Please try again later. The summary generation process is tracked in the "CodeQL Extension Log" view.',
);
}
private warnInProgressEvalLogViewer() { // Summary log file doesn't exist.
void showAndLogWarningMessage( if (evalLogLocation && (await pathExists(evalLogLocation))) {
this.app.logger, // If raw log does exist, then the summary log is still being generated.
"The viewer's data is still being generated for this run. Please try again or re-run the query.", void showAndLogWarningMessage(
); this.app.logger,
'The evaluator log summary is still being generated for this run. Please try again later. The summary generation process is tracked in the "CodeQL Extension Log" view.',
);
} else {
this.warnNoEvalLogs();
}
} }
async handleShowEvalLog(item: QueryHistoryInfo) { async handleShowEvalLog(item: QueryHistoryInfo) {
@ -800,8 +784,11 @@ export class QueryHistoryManager extends DisposableObject {
return; return;
} }
if (item.evalLogLocation) { const evalLogLocation =
await tryOpenExternalFile(this.app.commands, item.evalLogLocation); item.evalLogLocation ?? item.initialInfo.outputDir?.evalLogPath;
if (evalLogLocation && (await pathExists(evalLogLocation))) {
await tryOpenExternalFile(this.app.commands, evalLogLocation);
} else { } else {
this.warnNoEvalLogs(); this.warnNoEvalLogs();
} }
@ -812,18 +799,13 @@ export class QueryHistoryManager extends DisposableObject {
return; return;
} }
if (item.evalLogSummaryLocation) { // If the summary file location wasn't saved, display error
await tryOpenExternalFile(this.app.commands, item.evalLogSummaryLocation); if (!item.evalLogSummaryLocation) {
await this.warnNoEvalLogSummary(item);
return; return;
} }
// Summary log file doesn't exist. await tryOpenExternalFile(this.app.commands, item.evalLogSummaryLocation);
if (item.evalLogLocation && (await pathExists(item.evalLogLocation))) {
// If raw log does exist, then the summary log is still being generated.
this.warnInProgressEvalLogSummary();
} else {
this.warnNoEvalLogs();
}
} }
async handleShowEvalLogViewer(item: QueryHistoryInfo) { async handleShowEvalLogViewer(item: QueryHistoryInfo) {
@ -833,7 +815,7 @@ export class QueryHistoryManager extends DisposableObject {
// If the JSON summary file location wasn't saved, display error // If the JSON summary file location wasn't saved, display error
if (item.jsonEvalLogSummaryLocation === undefined) { if (item.jsonEvalLogSummaryLocation === undefined) {
this.warnInProgressEvalLogViewer(); await this.warnNoEvalLogSummary(item);
return; return;
} }