Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(download): remove abort event subscription #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,6 @@ export async function downloadTool(
file.end();
reject(err);
})
.on('aborted', () => {
// this block is for Node10 compatibility since it doesn't emit 'error' event after 'aborted' one
file.end();
reject(new Error('Aborted'));
})
.pipe(file);
} catch (err) {
reject(err);
Expand Down Expand Up @@ -303,16 +298,16 @@ export async function downloadTool(
}

export async function downloadToolWithRetries(
url: string,
fileName?: string,
handlers?: ifm.IRequestHandler[],
additionalHeaders?: ifm.IHeaders,
maxAttempts: number = 3,
retryInterval: number = 500
): Promise<string> {
url: string,
fileName?: string,
handlers?: ifm.IRequestHandler[],
additionalHeaders?: ifm.IHeaders,
maxAttempts: number = 3,
retryInterval: number = 500
): Promise<string> {
let attempt: number = 1;
let destinationPath: string = ''

while (attempt <= maxAttempts && destinationPath == '') {
try {
destinationPath = await downloadTool(url, fileName, handlers, additionalHeaders);
Expand All @@ -322,7 +317,7 @@ export async function downloadToolWithRetries(

// Error will be shown in downloadTool.
tl.debug(`Attempt ${attempt} failed. Retrying after ${attemptInterval} ms`);

await delay(attemptInterval);
attempt++;
}
Expand Down Expand Up @@ -500,10 +495,10 @@ export async function extract7z(file: string, dest?: string, _7zPath?: string, o
}

_7z.arg('x') // eXtract files with full paths
.arg('-bb1') // -bb[0-3] : set output log level
.arg('-bd') // disable progress indicator
.arg('-sccUTF-8') // set charset for for console input/output
.arg(file);
.arg('-bb1') // -bb[0-3] : set output log level
.arg('-bd') // disable progress indicator
.arg('-sccUTF-8') // set charset for for console input/output
.arg(file);
await _7z.exec();
}
else {
Expand Down