download at best effort

This commit is contained in:
fyears 2024-06-29 00:43:01 +08:00
parent e74e49538e
commit a2ce95441a

View File

@ -986,11 +986,24 @@ export class FakeFsOnedrive extends FakeFs {
).arrayBuffer; ).arrayBuffer;
return content; return content;
} else { } else {
// so strange, sometimes (!!!)
// we cannot download the file because of CORS
try {
// cannot set no-cache here, will have cors error // cannot set no-cache here, will have cors error
const content = await ( const content = await (
await fetch(downloadUrl, { cache: "no-store" }) await fetch(downloadUrl, { cache: "no-store" })
).arrayBuffer(); ).arrayBuffer();
return content; return content;
} catch (e) {
// let's try again to bypass the CORS
const content = (
await requestUrl({
url: downloadUrl,
headers: { "Cache-Control": "no-cache" },
})
).arrayBuffer;
return content;
}
} }
} }