fix(attachments): default download inline limit off (use export cache)
PEARCORD_ATTACHMENT_DOWNLOAD_MAX=0 sends full files via download-cache path. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -1408,7 +1408,11 @@ async function dispatchUiMessage (platform, msg, hooks = {}) {
|
||||
if (t === 'request-attachment-download') {
|
||||
const attachmentId = msg.attachmentId
|
||||
const downloadTimeoutMs = Number(process.env.PEARCORD_ATTACHMENT_DOWNLOAD_MS || 30000)
|
||||
const maxInlineBytes = Number(process.env.PEARCORD_ATTACHMENT_DOWNLOAD_MAX || 512 * 1024)
|
||||
const maxInlineRaw = process.env.PEARCORD_ATTACHMENT_DOWNLOAD_MAX
|
||||
const maxInlineBytes =
|
||||
maxInlineRaw === undefined || maxInlineRaw === '' || maxInlineRaw === '0'
|
||||
? 0
|
||||
: Number(maxInlineRaw)
|
||||
const sendDownloadError = (message) => {
|
||||
try {
|
||||
send({
|
||||
@@ -1428,7 +1432,7 @@ async function dispatchUiMessage (platform, msg, hooks = {}) {
|
||||
})
|
||||
])
|
||||
if (!exported?.filePath) throw new Error('attachment file empty')
|
||||
if (exported.size > maxInlineBytes) {
|
||||
if (maxInlineBytes > 0 && exported.size > maxInlineBytes) {
|
||||
try {
|
||||
send({
|
||||
type: 'attachment-download-saved',
|
||||
|
||||
Reference in New Issue
Block a user