fix(download): add checkUrlForFile timeout
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m5s

Fix #164
This commit is contained in:
enes 2025-01-17 12:51:52 +01:00
parent 32f35ebcca
commit d00b142231

View File

@ -127,8 +127,15 @@ export const downloadFile = (url: string, filename: string) => {
*/
export const checkUrlForFile = async (url: string) => {
try {
const controller = new AbortController()
const timeoutId = setTimeout(() => controller.abort(), 2000)
// HTTP HEAD request to get headers without downloading the full content
const response = await fetch(url, { method: 'HEAD' })
const response = await fetch(url, {
method: 'HEAD',
signal: controller.signal
})
clearTimeout(timeoutId)
// Check Content-Disposition header
const contentDisposition = response.headers.get('content-disposition')