@neelegirly/baileys 2.2.24 → 2.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -344,10 +344,18 @@ const getHttpStream = async (url, options = {}) => {
|
|
|
344
344
|
return fetched.data
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
+
const __ensureBaileysTmp = () => {
|
|
348
|
+
try {
|
|
349
|
+
const __tmpDir = path_1.join(process.cwd(), 'tmp')
|
|
350
|
+
if (!fs_1.existsSync(__tmpDir)) fs_1.mkdirSync(__tmpDir, { recursive: true })
|
|
351
|
+
} catch (_) { /* never break the caller */ }
|
|
352
|
+
}
|
|
353
|
+
|
|
347
354
|
const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequired, opts } = {}) => {
|
|
348
355
|
const { stream, type } = await getStream(media, opts)
|
|
349
356
|
logger?.debug('fetched media stream')
|
|
350
357
|
|
|
358
|
+
__ensureBaileysTmp()
|
|
351
359
|
const encFilePath = path_1.join(process.cwd(), 'tmp', mediaType + generics_1.generateMessageID() + '-plain')
|
|
352
360
|
const encFileWriteStream = fs_1.createWriteStream(encFilePath)
|
|
353
361
|
|
|
@@ -423,6 +431,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
423
431
|
logger?.debug('fetched media stream')
|
|
424
432
|
const mediaKey = Crypto.randomBytes(32)
|
|
425
433
|
const { cipherKey, iv, macKey } = await getMediaKeys(mediaKey, mediaType)
|
|
434
|
+
__ensureBaileysTmp()
|
|
426
435
|
const encFilePath = path_1.join(process.cwd(), 'tmp', mediaType + generics_1.generateMessageID() + '-enc')
|
|
427
436
|
const encFileWriteStream = fs_1.createWriteStream(encFilePath)
|
|
428
437
|
let originalFileStream
|