Merge pull request #2115 from Bilb/fix-attachment-decrypt-fail-exception

catch exception when failing to decode/read an attachment
pull/2118/head
Audric Ackermann 3 years ago committed by GitHub
commit a070827d22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -84,6 +84,8 @@ export const getDecryptedMediaUrl = async (
urlToDecryptingPromise.set( urlToDecryptingPromise.set(
url, url,
new Promise(async resolve => { new Promise(async resolve => {
window.log.info('about to read and decrypt file :', url);
try {
const encryptedFileContent = await fse.readFile(url); const encryptedFileContent = await fse.readFile(url);
const decryptedContent = await decryptAttachmentBuffer( const decryptedContent = await decryptAttachmentBuffer(
toArrayBuffer(encryptedFileContent) toArrayBuffer(encryptedFileContent)
@ -100,6 +102,7 @@ export const getDecryptedMediaUrl = async (
forceRetain: isAvatar, forceRetain: isAvatar,
}); });
} }
window.log.info(' file decrypted :', url);
urlToDecryptingPromise.delete(url); urlToDecryptingPromise.delete(url);
resolve(obj); resolve(obj);
return; return;
@ -107,9 +110,14 @@ export const getDecryptedMediaUrl = async (
// failed to decrypt, fallback to url image loading // failed to decrypt, fallback to url image loading
// it might be a media we received before the update encrypting attachments locally. // it might be a media we received before the update encrypting attachments locally.
urlToDecryptingPromise.delete(url); urlToDecryptingPromise.delete(url);
window.log.info('error decrypting file :', url);
resolve(url); resolve(url);
return; return;
} }
} catch (e) {
window.log.warn(e);
}
}) })
); );

Loading…
Cancel
Save