1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Mobile: Avoid crash when downloading large files (#3113)

This commit is contained in:
roman-r-m 2020-05-09 11:52:09 +01:00 committed by GitHub
parent c593546575
commit e768b8cfea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,10 +83,16 @@ function shimInit() {
const output = { const output = {
ok: response.respInfo.status < 400, ok: response.respInfo.status < 400,
path: response.data, path: response.data,
text: response.text,
json: response.json,
status: response.respInfo.status, status: response.respInfo.status,
headers: response.respInfo.headers, headers: response.respInfo.headers,
// If response type is 'path' then calling text() or json() (or base64())
// on RNFetchBlob response object will make it read the file on the native thread,
// serialize it, and send over the RN bridge.
// For larger files this can cause the app to crash.
// For these type of responses we're not using the response text anyway
// so can override it here to return empty values
text: response.type === 'path' ? () => '' : response.text,
json: response.type === 'path' ? () => {} : response.json,
}; };
return output; return output;