mirror of https://github.com/actions/toolkit
Fix linter
parent
8cf7e029de
commit
6d304fe599
|
@ -92,19 +92,19 @@ export class DownloadProgress {
|
||||||
}
|
}
|
||||||
|
|
||||||
setLastTimeOfNewBytes(): void {
|
setLastTimeOfNewBytes(): void {
|
||||||
this.lastTimeOfNewBytes = Date.now();
|
this.lastTimeOfNewBytes = Date.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
getLastTimeOfNewBytes(): number | undefined {
|
getLastTimeOfNewBytes(): number | undefined {
|
||||||
return this.lastTimeOfNewBytes;
|
return this.lastTimeOfNewBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
setAbortController(abortReference: AbortController): void {
|
setAbortController(abortReference: AbortController): void {
|
||||||
this.abortController = abortReference;
|
this.abortController = abortReference
|
||||||
}
|
}
|
||||||
|
|
||||||
triggerAbortController(): void {
|
triggerAbortController(): void {
|
||||||
this.abortController?.abort();
|
this.abortController?.abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,11 +149,15 @@ export class DownloadProgress {
|
||||||
onProgress(): (progress: TransferProgressEvent) => void {
|
onProgress(): (progress: TransferProgressEvent) => void {
|
||||||
return (progress: TransferProgressEvent) => {
|
return (progress: TransferProgressEvent) => {
|
||||||
if (progress.loadedBytes > this.getTransferredBytes()) {
|
if (progress.loadedBytes > this.getTransferredBytes()) {
|
||||||
this.setReceivedBytes(progress.loadedBytes);
|
this.setReceivedBytes(progress.loadedBytes)
|
||||||
this.setLastTimeOfNewBytes();
|
this.setLastTimeOfNewBytes()
|
||||||
} else {
|
} else {
|
||||||
if (this.getLastTimeOfNewBytes !== undefined && Date.now() - this.getLastTimeOfNewBytes()! > 120000) { // if download hanging for more than 2 minutes
|
// if download hanging for more than 2 minutes
|
||||||
this.triggerAbortController();
|
if (
|
||||||
|
this.getLastTimeOfNewBytes() !== undefined &&
|
||||||
|
Date.now() - this.getLastTimeOfNewBytes()! > 120000
|
||||||
|
) {
|
||||||
|
this.triggerAbortController()
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Aborting cache download as the download has stalled for more than 2 minutes.'
|
'Aborting cache download as the download has stalled for more than 2 minutes.'
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue