🚑 Do not throw error if file too large in download module
This commit is contained in:
parent
e4d906e48c
commit
34a4372183
2 changed files with 4 additions and 9 deletions
|
@ -1,9 +1,6 @@
|
|||
import * as fs from 'fs';
|
||||
import * as http from 'http';
|
||||
|
||||
/** Too avoid overloading the server, do not allow large files (> 100 MB) to be handled in memory. */
|
||||
const MAX_MEMORY_SIZE = 100 * 1024 * 1024;
|
||||
|
||||
export default function saveResponse(
|
||||
resolve: (fileName: fs.ReadStream) => void,
|
||||
reject: (reason: string) => void,
|
||||
|
@ -14,11 +11,8 @@ export default function saveResponse(
|
|||
return reject(`Expected status code 200 but received ${response.statusCode}.`);
|
||||
}
|
||||
|
||||
//Check file size
|
||||
//Remember file size
|
||||
const headerLength = Number(response.headers['content-length']);
|
||||
if (headerLength > MAX_MEMORY_SIZE) {
|
||||
return reject(`File size (${headerLength} bytes) too large to be handled in memory.`);
|
||||
}
|
||||
|
||||
const tempFileName = `'/tmp/swtor-patcher-download-${Math.random()}.tmp`;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue