mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-07 18:01:42 +00:00
Merge b2ba94eced into 354e0bf793
This commit is contained in:
commit
2e1294dd63
8 changed files with 281 additions and 6 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
|
||||
|
|
|
|||
|
|
@ -9,7 +9,11 @@ module.exports.zipDirectoryPipe = (path, filename, res) => {
|
|||
res.attachment(filename)
|
||||
|
||||
const archive = archiver('zip', {
|
||||
zlib: { level: 0 } // Sets the compression level.
|
||||
zlib: { level: 0 }, // Sets the compression level (0 = store, no CPU overhead).
|
||||
// Increase the internal pipeline highWaterMark from 16 KiB to 512 KiB.
|
||||
// This allows archiver to buffer more data before applying backpressure,
|
||||
// keeping the read-from-disk and write-to-network pipelines busy.
|
||||
highWaterMark: 524288
|
||||
})
|
||||
|
||||
// listen for all archive data to be written
|
||||
|
|
@ -67,7 +71,9 @@ module.exports.zipDirectoriesPipe = (pathObjects, filename, res) => {
|
|||
res.attachment(filename)
|
||||
|
||||
const archive = archiver('zip', {
|
||||
zlib: { level: 0 } // Sets the compression level.
|
||||
zlib: { level: 0 }, // Sets the compression level (0 = store, no CPU overhead).
|
||||
// Increase the internal pipeline highWaterMark from 16 KiB to 512 KiB.
|
||||
highWaterMark: 524288
|
||||
})
|
||||
|
||||
// listen for all archive data to be written
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue