Clear tmp media files + regen yarn lock

This commit is contained in:
Adhiraj Singh
2021-04-12 21:01:20 +05:30
parent 3575150df1
commit 3b2618910c
5 changed files with 398 additions and 429 deletions

View File

@@ -155,7 +155,8 @@ export class WAConnection extends Base {
bodyPath,
fileEncSha256,
fileSha256,
fileLength
fileLength,
didSaveToTmpPath
} = await encryptedStream(media, mediaType, requiresOriginalForSomeProcessing)
// url safe Base64 encode the SHA256 hash of the body
const fileEncSha256B64 = encodeURIComponent(
@@ -204,6 +205,14 @@ export class WAConnection extends Base {
}
}
if (!mediaUrl) throw new Error('Media upload failed on all hosts')
// remove tmp files
await Promise.all(
[
fs.unlink(encBodyPath),
didSaveToTmpPath && bodyPath && fs.unlink(bodyPath)
]
.filter(Boolean)
)
const message = {
[mediaType]: MessageTypeProto[mediaType].fromObject(

View File

@@ -382,7 +382,8 @@ export const encryptedStream = async(media: WAMediaUpload, mediaType: MessageTyp
mac,
fileEncSha256,
fileSha256,
fileLength
fileLength,
didSaveToTmpPath: type !== 'file'
}
}
/**