mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-08 02:11:35 +00:00
Fix slow downloads: larger buffers, Content-Length headers, parallel streams
This commit is contained in:
parent
c010f0e1eb
commit
cf0a432027
3 changed files with 22 additions and 4 deletions
|
|
@ -318,8 +318,9 @@ module.exports.downloadFile = (url, filepath, contentTypeFilter = null) => {
|
|||
const totalSize = parseInt(response.headers['content-length'], 10)
|
||||
let downloadedSize = 0
|
||||
|
||||
// Write to filepath
|
||||
const writer = fs.createWriteStream(filepath)
|
||||
// Use a 512 KiB write buffer. Node's default 16 KiB highWaterMark causes
|
||||
// many small write syscalls for large audio files and limits throughput.
|
||||
const writer = fs.createWriteStream(filepath, { highWaterMark: 524288 })
|
||||
response.data.pipe(writer)
|
||||
|
||||
let lastProgress = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue