Report decryption failures to Sentry (#1308)
This commit is contained in:
commit
a43f7d2bbb
|
@ -51,16 +51,20 @@ Future<io.File?> downloadAndDecrypt(
|
|||
final decryptedFilePath = Configuration.instance.getTempDirectory() +
|
||||
file.generatedID.toString() +
|
||||
".decrypted";
|
||||
final decryptedFile = io.File(decryptedFilePath);
|
||||
await CryptoUtil.decryptFile(
|
||||
encryptedFilePath,
|
||||
decryptedFilePath,
|
||||
CryptoUtil.base642bin(file.fileDecryptionHeader!),
|
||||
getFileKey(file),
|
||||
);
|
||||
try {
|
||||
await CryptoUtil.decryptFile(
|
||||
encryptedFilePath,
|
||||
decryptedFilePath,
|
||||
CryptoUtil.base642bin(file.fileDecryptionHeader!),
|
||||
getFileKey(file),
|
||||
);
|
||||
} catch (e, s) {
|
||||
_logger.severe("Failed to decrypt file", e, s);
|
||||
return null;
|
||||
}
|
||||
_logger.info("File decrypted: " + file.uploadedFileID.toString());
|
||||
await encryptedFile.delete();
|
||||
return decryptedFile;
|
||||
return io.File(decryptedFilePath);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -158,11 +158,18 @@ Future<void> _downloadAndDecryptThumbnail(FileDownloadItem item) async {
|
|||
return;
|
||||
}
|
||||
final thumbnailDecryptionKey = await getFileKeyUsingBgWorker(file);
|
||||
var data = await CryptoUtil.decryptChaCha(
|
||||
encryptedThumbnail,
|
||||
thumbnailDecryptionKey,
|
||||
CryptoUtil.base642bin(file.thumbnailDecryptionHeader!),
|
||||
);
|
||||
Uint8List data;
|
||||
try {
|
||||
data = await CryptoUtil.decryptChaCha(
|
||||
encryptedThumbnail,
|
||||
thumbnailDecryptionKey,
|
||||
CryptoUtil.base642bin(file.thumbnailDecryptionHeader!),
|
||||
);
|
||||
} catch (e, s) {
|
||||
_logger.severe("Failed to decrypt thumbnail", e, s);
|
||||
item.completer.completeError(e);
|
||||
return;
|
||||
}
|
||||
final thumbnailSize = data.length;
|
||||
if (thumbnailSize > thumbnailDataLimit) {
|
||||
data = await compressThumbnail(data);
|
||||
|
|
Loading…
Reference in a new issue