Skip to content

Commit

Permalink
Fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
cwille97 committed Jun 19, 2023
1 parent 8cf7e02 commit 6d304fe
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/cache/src/internal/downloadUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ export class DownloadProgress {
}

setLastTimeOfNewBytes(): void {
this.lastTimeOfNewBytes = Date.now();
this.lastTimeOfNewBytes = Date.now()
}

getLastTimeOfNewBytes(): number | undefined {
return this.lastTimeOfNewBytes;
return this.lastTimeOfNewBytes
}

setAbortController(abortReference: AbortController): void {
this.abortController = abortReference;
this.abortController = abortReference
}

triggerAbortController(): void {
this.abortController?.abort();
this.abortController?.abort()
}

/**
Expand Down Expand Up @@ -149,11 +149,15 @@ export class DownloadProgress {
onProgress(): (progress: TransferProgressEvent) => void {
return (progress: TransferProgressEvent) => {
if (progress.loadedBytes > this.getTransferredBytes()) {
this.setReceivedBytes(progress.loadedBytes);
this.setLastTimeOfNewBytes();
this.setReceivedBytes(progress.loadedBytes)
this.setLastTimeOfNewBytes()
} else {
if (this.getLastTimeOfNewBytes !== undefined && Date.now() - this.getLastTimeOfNewBytes()! > 120000) { // if download hanging for more than 2 minutes
this.triggerAbortController();
// if download hanging for more than 2 minutes
if (
this.getLastTimeOfNewBytes() !== undefined &&
Date.now() - this.getLastTimeOfNewBytes()! > 120000

Check warning on line 158 in packages/cache/src/internal/downloadUtils.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

Forbidden non-null assertion

Check warning on line 158 in packages/cache/src/internal/downloadUtils.ts

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

Forbidden non-null assertion

Check warning on line 158 in packages/cache/src/internal/downloadUtils.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

Forbidden non-null assertion
) {
this.triggerAbortController()
throw new Error(
'Aborting cache download as the download has stalled for more than 2 minutes.'
)
Expand Down

0 comments on commit 6d304fe

Please sign in to comment.