Skip to content

Commit 2fc66b7

Browse files
committed
Fix duplicate artifact downloads (again)
1 parent 0ce6883 commit 2fc66b7

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

dist/index.js

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ export class GitHubApiClient implements ProviderAPIClient {
1212

1313
private readonly octokit
1414

15-
private readonly artifactCache = new Map<string, DownloadedArtifact | null>()
15+
private readonly artifactCache = new Map<
16+
string,
17+
Promise<DownloadedArtifact | null>
18+
>()
1619

1720
constructor(
1821
private readonly token: string,
@@ -82,17 +85,18 @@ export class GitHubApiClient implements ProviderAPIClient {
8285
private async getReportsArtifact(
8386
base: GitBranch
8487
): Promise<DownloadedArtifact | null> {
85-
if (this.artifactCache.has(base.sha)) {
86-
return this.artifactCache.get(base.sha) ?? null
88+
const cached = this.artifactCache.get(base.sha)
89+
if (cached) {
90+
return cached
8791
}
88-
const result = await downloadReportsArtifact(
92+
const promise = downloadReportsArtifact(
8993
this.artifact,
9094
this.octokit,
9195
base,
9296
this.token
9397
)
94-
this.artifactCache.set(base.sha, result)
95-
return result
98+
this.artifactCache.set(base.sha, promise)
99+
return promise
96100
}
97101

98102
private convertComment(

0 commit comments

Comments
 (0)