Fix thumbnails of received encrypted images

This commit is contained in:
Nicolas Werner 2022-03-22 04:32:11 +01:00
parent 43a1975e16
commit 30ba387076
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
2 changed files with 8 additions and 3 deletions

View File

@ -65,9 +65,9 @@ MxcImageRunnable::run()
MxcImageProvider::download( MxcImageProvider::download(
m_id, m_id,
m_requestedSize, m_requestedSize,
[this](QString, QSize, QImage image, QString) { [this](QString id, QSize, QImage image, QString) {
if (image.isNull()) { if (image.isNull()) {
emit error(QStringLiteral("Failed to download image.")); emit error(QStringLiteral("Failed to download image: %1").arg(id));
} else { } else {
emit done(image); emit done(image);
} }
@ -157,7 +157,6 @@ MxcImageProvider::download(const QString &id,
mtx::http::RequestErr err) { mtx::http::RequestErr err) {
if (err || res.empty()) { if (err || res.empty()) {
download(id, QSize(), then, crop, radius); download(id, QSize(), then, crop, radius);
return; return;
} }
@ -237,6 +236,7 @@ MxcImageProvider::download(const QString &id,
const std::string &originalFilename, const std::string &originalFilename,
mtx::http::RequestErr err) { mtx::http::RequestErr err) {
if (err) { if (err) {
nhlog::net()->error("Failed to download {}: {}", id.toStdString(), *err);
then(id, QSize(), {}, QLatin1String("")); then(id, QSize(), {}, QLatin1String(""));
return; return;
} }
@ -244,6 +244,8 @@ MxcImageProvider::download(const QString &id,
auto tempData = res; auto tempData = res;
QFile f(fileInfo.absoluteFilePath()); QFile f(fileInfo.absoluteFilePath());
if (!f.open(QIODevice::Truncate | QIODevice::WriteOnly)) { if (!f.open(QIODevice::Truncate | QIODevice::WriteOnly)) {
nhlog::net()->error(
"Failed to write {}: {}", id.toStdString(), f.errorString().toStdString());
then(id, QSize(), {}, QLatin1String("")); then(id, QSize(), {}, QLatin1String(""));
return; return;
} }

View File

@ -720,6 +720,9 @@ EventStore::decryptEvent(const IdIndex &idx,
} }
auto encInfo = mtx::accessors::file(decryptionResult.event.value()); auto encInfo = mtx::accessors::file(decryptionResult.event.value());
if (encInfo)
emit newEncryptedImage(encInfo.value());
encInfo = mtx::accessors::thumbnail_file(decryptionResult.event.value());
if (encInfo) if (encInfo)
emit newEncryptedImage(encInfo.value()); emit newEncryptedImage(encInfo.value());