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(
|
||||
getTmpFilesDirectory(),
|
||||
mediaType + generateMessageIDV2() + "-enc"
|
||||
);
|
||||
const encFileWriteStream = createWriteStream(encFilePath);
|
||||
mediaType + generateMessageIDV2() + '-enc'
|
||||
)
|
||||
const encFileWriteStream = createWriteStream(encFilePath)
|
||||
|
||||
let originalFileStream: WriteStream | undefined;
|
||||
let originalFilePath: string | undefined;
|
||||
let originalFileStream: WriteStream | undefined
|
||||
let originalFilePath: string | undefined
|
||||
|
||||
if (saveOriginalFileIfRequired) {
|
||||
if(saveOriginalFileIfRequired) {
|
||||
originalFilePath = join(
|
||||
getTmpFilesDirectory(),
|
||||
mediaType + generateMessageIDV2() + "-original"
|
||||
);
|
||||
originalFileStream = createWriteStream(originalFilePath);
|
||||
mediaType + generateMessageIDV2() + '-original'
|
||||
)
|
||||
originalFileStream = createWriteStream(originalFilePath)
|
||||
}
|
||||
|
||||
let fileLength = 0
|
||||
@@ -370,10 +370,10 @@ export const encryptedStream = async(
|
||||
const sha256Enc = Crypto.createHash('sha256')
|
||||
|
||||
const onChunk = (buff: Buffer) => {
|
||||
sha256Enc.update(buff);
|
||||
hmac.update(buff);
|
||||
encFileWriteStream.write(buff);
|
||||
};
|
||||
sha256Enc.update(buff)
|
||||
hmac.update(buff)
|
||||
encFileWriteStream.write(buff)
|
||||
}
|
||||
|
||||
try {
|
||||
for await (const data of stream) {
|
||||
@@ -392,9 +392,9 @@ export const encryptedStream = async(
|
||||
)
|
||||
}
|
||||
|
||||
if (originalFileStream) {
|
||||
if (!originalFileStream.write(data)) {
|
||||
await once(originalFileStream, "drain");
|
||||
if(originalFileStream) {
|
||||
if(!originalFileStream.write(data)) {
|
||||
await once(originalFileStream, 'drain')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,11 +410,11 @@ export const encryptedStream = async(
|
||||
const fileSha256 = sha256Plain.digest()
|
||||
const fileEncSha256 = sha256Enc.digest()
|
||||
|
||||
encFileWriteStream.write(mac);
|
||||
encFileWriteStream.write(mac)
|
||||
|
||||
encFileWriteStream.end();
|
||||
originalFileStream?.end?.();
|
||||
stream.destroy();
|
||||
encFileWriteStream.end()
|
||||
originalFileStream?.end?.()
|
||||
stream.destroy()
|
||||
|
||||
logger?.debug('encrypted data successfully')
|
||||
|
||||
@@ -440,10 +440,13 @@ export const encryptedStream = async(
|
||||
|
||||
try {
|
||||
await fs.unlink(encFilePath)
|
||||
if (originalFilePath) await fs.unlink(originalFilePath)
|
||||
if(originalFilePath) {
|
||||
await fs.unlink(originalFilePath)
|
||||
}
|
||||
} catch(err) {
|
||||
logger?.error({ err }, 'failed deleting tmp files')
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user