MR: Address reviewer feedback: remove dotfiles option, fix keepAliveTimeout comment

This commit is contained in:
Trevor Renshaw 2026-05-17 09:41:20 -06:00
parent 09a84837cf
commit b2ba94eced
3 changed files with 10 additions and 17 deletions

View file

@ -301,9 +301,9 @@ class Server {
app.disable('x-powered-by')
this.server = http.createServer(app)
// Keep connections alive for 120s so multi-file downloads don't pay a new
// TCP handshake per file. Default Node.js keepAliveTimeout is only 5s,
// which causes connections to drop mid-download for files > 5s.
// Extend keep-alive timeout to 120s. Node's default (5s) closes idle
// connections quickly, forcing a new TCP handshake for each file when a
// client downloads multiple files in sequence (e.g. individual chapters).
this.server.keepAliveTimeout = 120000
this.server.headersTimeout = 125000

View file

@ -187,7 +187,7 @@ class LibraryItemController {
// Use sendFile so the `send` module sets Content-Length, Accept-Ranges,
// and handles range requests natively — no extra stat() call needed.
res.setHeader('Content-Disposition', `attachment; filename="${encodeURIComponent(Path.basename(req.libraryItem.relPath))}"`)
await new Promise((resolve, reject) => res.sendFile(libraryItemPath, { dotfiles: 'allow' }, (error) => (error ? reject(error) : resolve())))
await new Promise((resolve, reject) => res.sendFile(libraryItemPath, (error) => (error ? reject(error) : resolve())))
} else {
const filename = `${itemTitle}.zip`
await zipHelpers.zipDirectoryPipe(libraryItemPath, filename, res)
@ -1103,7 +1103,7 @@ class LibraryItemController {
// Use sendFile so the `send` module sets Content-Length, Accept-Ranges,
// and handles range requests natively — no extra stat() call needed.
res.setHeader('Content-Disposition', `attachment; filename="${encodeURIComponent(libraryFile.metadata.filename)}"`)
await new Promise((resolve, reject) => res.sendFile(libraryFile.metadata.path, { dotfiles: 'allow' }, (error) => (error ? reject(error) : resolve())))
await new Promise((resolve, reject) => res.sendFile(libraryFile.metadata.path, (error) => (error ? reject(error) : resolve())))
Logger.info(`[LibraryItemController] Downloaded file "${libraryFile.metadata.path}"`)
} catch (error) {
Logger.error(`[LibraryItemController] Failed to download file "${libraryFile.metadata.path}"`, error)