From 14684e0901c06c522bc9355619d19903212041cc Mon Sep 17 00:00:00 2001 From: "kirill.moos" Date: Thu, 14 May 2026 09:39:24 +0300 Subject: [PATCH] fix emoji donwloadStream --- lib/rocketchat/emoji.js | 17 ++++++++++------- lib/rocketchat/utils.js | 4 +++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/rocketchat/emoji.js b/lib/rocketchat/emoji.js index fea96b0..7b71e19 100644 --- a/lib/rocketchat/emoji.js +++ b/lib/rocketchat/emoji.js @@ -20,14 +20,17 @@ module.exports = async function (context) { const filename = `${result.name}.${result.extension}` const dest = `${context.config.target.filesPath}/custom_emoji/${filename}` - const srcFilename = Utils.srcPath(context.config.source.customEmojiPath, filename) - if (srcFilename) { - Utils.copyFile(srcFilename, dest) - } else { - await Utils.downloadGridFSByName(context, fileCollection, filename, dest) + try { + const srcFilename = Utils.srcPath(context.config.source.customEmojiPath, filename) + if (srcFilename) { + Utils.copyFile(srcFilename, dest) + } else { + await Utils.downloadGridFSByName(context, fileCollection, filename, dest) + } + log.info(`... copied ${result.name}`) + } catch (err) { + log.warn(`... skipping emoji "${result.name}": ${err.message}`) } - - log.info(`... copied ${result.name}`) } return context } diff --git a/lib/rocketchat/utils.js b/lib/rocketchat/utils.js index 7bd26eb..9c8a79b 100644 --- a/lib/rocketchat/utils.js +++ b/lib/rocketchat/utils.js @@ -182,10 +182,12 @@ utils.downloadGridFSByName = async function (context, collection, filename, dest const bucket = context.rocketchat.gridFsBucket(collection.collectionName) const destStream = fs.createWriteStream(dest) - bucket.openDownloadStreamByName(filename).pipe(destStream) + const downloadStream = bucket.openDownloadStreamByName(filename) + downloadStream.pipe(destStream) return new Promise((resolve, reject) => { destStream.on('finish', resolve) destStream.on('error', reject) + downloadStream.on('error', reject) }) }