mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
chore: lint
This commit is contained in:
@@ -348,19 +348,19 @@ export const encryptedStream = async(
|
|||||||
|
|
||||||
const encFilePath = join(
|
const encFilePath = join(
|
||||||
getTmpFilesDirectory(),
|
getTmpFilesDirectory(),
|
||||||
mediaType + generateMessageIDV2() + "-enc"
|
mediaType + generateMessageIDV2() + '-enc'
|
||||||
);
|
)
|
||||||
const encFileWriteStream = createWriteStream(encFilePath);
|
const encFileWriteStream = createWriteStream(encFilePath)
|
||||||
|
|
||||||
let originalFileStream: WriteStream | undefined;
|
let originalFileStream: WriteStream | undefined
|
||||||
let originalFilePath: string | undefined;
|
let originalFilePath: string | undefined
|
||||||
|
|
||||||
if (saveOriginalFileIfRequired) {
|
if(saveOriginalFileIfRequired) {
|
||||||
originalFilePath = join(
|
originalFilePath = join(
|
||||||
getTmpFilesDirectory(),
|
getTmpFilesDirectory(),
|
||||||
mediaType + generateMessageIDV2() + "-original"
|
mediaType + generateMessageIDV2() + '-original'
|
||||||
);
|
)
|
||||||
originalFileStream = createWriteStream(originalFilePath);
|
originalFileStream = createWriteStream(originalFilePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
let fileLength = 0
|
let fileLength = 0
|
||||||
@@ -370,10 +370,10 @@ export const encryptedStream = async(
|
|||||||
const sha256Enc = Crypto.createHash('sha256')
|
const sha256Enc = Crypto.createHash('sha256')
|
||||||
|
|
||||||
const onChunk = (buff: Buffer) => {
|
const onChunk = (buff: Buffer) => {
|
||||||
sha256Enc.update(buff);
|
sha256Enc.update(buff)
|
||||||
hmac.update(buff);
|
hmac.update(buff)
|
||||||
encFileWriteStream.write(buff);
|
encFileWriteStream.write(buff)
|
||||||
};
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for await (const data of stream) {
|
for await (const data of stream) {
|
||||||
@@ -392,9 +392,9 @@ export const encryptedStream = async(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (originalFileStream) {
|
if(originalFileStream) {
|
||||||
if (!originalFileStream.write(data)) {
|
if(!originalFileStream.write(data)) {
|
||||||
await once(originalFileStream, "drain");
|
await once(originalFileStream, 'drain')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,11 +410,11 @@ export const encryptedStream = async(
|
|||||||
const fileSha256 = sha256Plain.digest()
|
const fileSha256 = sha256Plain.digest()
|
||||||
const fileEncSha256 = sha256Enc.digest()
|
const fileEncSha256 = sha256Enc.digest()
|
||||||
|
|
||||||
encFileWriteStream.write(mac);
|
encFileWriteStream.write(mac)
|
||||||
|
|
||||||
encFileWriteStream.end();
|
encFileWriteStream.end()
|
||||||
originalFileStream?.end?.();
|
originalFileStream?.end?.()
|
||||||
stream.destroy();
|
stream.destroy()
|
||||||
|
|
||||||
logger?.debug('encrypted data successfully')
|
logger?.debug('encrypted data successfully')
|
||||||
|
|
||||||
@@ -440,10 +440,13 @@ export const encryptedStream = async(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await fs.unlink(encFilePath)
|
await fs.unlink(encFilePath)
|
||||||
if (originalFilePath) await fs.unlink(originalFilePath)
|
if(originalFilePath) {
|
||||||
|
await fs.unlink(originalFilePath)
|
||||||
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
logger?.error({ err }, 'failed deleting tmp files')
|
logger?.error({ err }, 'failed deleting tmp files')
|
||||||
}
|
}
|
||||||
|
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user