Skip to content

Commit 60df319

Browse files
committed
Save repo task object to storage
To create the interpreted and raw results from the SARIF/BQRS files, we need some information from the repo task object. This will store the repo task object to the filesystem as JSON so we can read them when loading results.
1 parent 0bdee6e commit 60df319

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

extensions/ql-vscode/src/remote-queries/variant-analysis-results-manager.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export type ResultDownloadedEvent = {
2525
}
2626

2727
export class VariantAnalysisResultsManager extends DisposableObject {
28+
private static readonly REPO_TASK_FILENAME = 'repo_task.json';
29+
2830
private readonly cachedResults: Map<CacheKey, VariantAnalysisScannedRepositoryResult>;
2931

3032
private readonly _onResultDownloaded = this.push(new EventEmitter<ResultDownloadedEvent>());
@@ -59,6 +61,7 @@ export class VariantAnalysisResultsManager extends DisposableObject {
5961
);
6062

6163
fs.mkdirSync(resultDirectory, { recursive: true });
64+
await fs.outputJson(path.join(resultDirectory, VariantAnalysisResultsManager.REPO_TASK_FILENAME), repoTask);
6265
await fs.writeFile(path.join(resultDirectory, 'results.zip'), JSON.stringify(result, null, 2), 'utf8');
6366

6467
this._onResultDownloaded.fire({
@@ -94,14 +97,16 @@ export class VariantAnalysisResultsManager extends DisposableObject {
9497
throw new Error('Variant analysis results not downloaded');
9598
}
9699

100+
const storageDirectory = this.getRepoStorageDirectory(variantAnalysisId, repositoryFullName);
101+
102+
const repoTask: VariantAnalysisRepoTask = await fs.readJson(path.join(storageDirectory, VariantAnalysisResultsManager.REPO_TASK_FILENAME));
103+
97104
if (!repoTask.database_commit_sha || !repoTask.source_location_prefix) {
98105
throw new Error('Missing database commit SHA');
99106
}
100107

101108
const fileLinkPrefix = this.createGitHubDotcomFileLinkPrefix(repoTask.repository.full_name, repoTask.database_commit_sha);
102109

103-
const storageDirectory = this.getRepoStorageDirectory(variantAnalysisId, repositoryFullName);
104-
105110
const sarifPath = path.join(storageDirectory, 'results.sarif');
106111
const bqrsPath = path.join(storageDirectory, 'results.bqrs');
107112
if (await fs.pathExists(sarifPath)) {

0 commit comments

Comments
 (0)