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

[UX] Ignore error message fetching non-existent known-fix json #3701

Merged
merged 2 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/backend/downloadmanager/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async function downloadFixesFor(appName: string, runner: Runner) {
if (!existsSync(fixesPath)) {
mkdirSync(fixesPath, { recursive: true })
}
downloadFile({ url, dest })
downloadFile({ url, dest, ignoreFailure: true })
}

export { installQueueElement, updateQueueElement }
33 changes: 22 additions & 11 deletions src/backend/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,7 @@ interface DownloadArgs {
dest: string
abortSignal?: AbortSignal
progressCallback?: ProgressCallback
ignoreFailure?: boolean
}

/**
Expand All @@ -1258,14 +1259,16 @@ interface DownloadArgs {
* @param {string} dest - The destination path to save the downloaded file.
* @param {AbortSignal} abortSignal - The AbortSignal instance to cancel the download.
* @param {ProgressCallback} [progressCallback] - An optional callback function to track the download progress.
* @param {boolean} ignoreFailure - When "true", failure to download the file is ignore (no log and no thrown error).
* @returns {Promise<void>} - A Promise that resolves when the download is complete.
* @throws {Error} - If the download fails or is incomplete.
*/
export async function downloadFile({
url,
dest,
abortSignal,
progressCallback
progressCallback,
ignoreFailure
}: DownloadArgs): Promise<void> {
let lastProgressUpdateTime = Date.now()
let lastBytesWritten = 0
Expand All @@ -1276,11 +1279,15 @@ export async function downloadFile({
const response = await axiosClient.head(url)
fileSize = parseInt(response.headers['content-length'], 10)
} catch (err) {
logError(
`Downloader: Failed to get headers for ${url}. \nError: ${err}`,
LogPrefix.DownloadManager
)
throw new Error('Failed to get headers')
if (!ignoreFailure) {
logError(
`Downloader: Failed to get headers for ${url}. \nError: ${err}`,
LogPrefix.DownloadManager
)
throw new Error('Failed to get headers')
} else {
return
}
}

try {
Expand Down Expand Up @@ -1352,11 +1359,15 @@ export async function downloadFile({
LogPrefix.DownloadManager
)
} catch (err) {
logError(
`Downloader: Download Failed with: ${err}`,
LogPrefix.DownloadManager
)
throw new Error(`Download failed with ${err}`)
if (!ignoreFailure) {
logError(
`Downloader: Download Failed with: ${err}`,
LogPrefix.DownloadManager
)
throw new Error(`Download failed with ${err}`)
} else {
return
}
}
}

Expand Down
Loading