Commit 5571dd56 authored by Marcin Gurtowski's avatar Marcin Gurtowski Committed by David Faure
Browse files

Skipping thumbnail caching for encrypted storages

parent 98520e6c
Pipeline #64335 passed with stage
in 4 minutes and 2 seconds
...@@ -41,7 +41,7 @@ target_link_libraries(kio_thumbnail ...@@ -41,7 +41,7 @@ target_link_libraries(kio_thumbnail
KF5::CoreAddons KF5::CoreAddons
KF5::KIOCore KF5::KIOCore
KF5::KIOWidgets KF5::KIOWidgets
KF5::I18n KF5::I18n
) )
set_target_properties(kio_thumbnail PROPERTIES OUTPUT_NAME "thumbnail") set_target_properties(kio_thumbnail PROPERTIES OUTPUT_NAME "thumbnail")
......
...@@ -690,19 +690,28 @@ bool ThumbnailProtocol::createSubThumbnail(QImage &thumbnail, const QString &fil ...@@ -690,19 +690,28 @@ bool ThumbnailProtocol::createSubThumbnail(QImage &thumbnail, const QString &fil
if (subCreator && subCreator->create(filePath, cacheSize, cacheSize, thumbnail)) { if (subCreator && subCreator->create(filePath, cacheSize, cacheSize, thumbnail)) {
scaleDownImage(thumbnail, cacheSize, cacheSize); scaleDownImage(thumbnail, cacheSize, cacheSize);
// The thumbnail has been created successfully. Store the thumbnail // The thumbnail has been created successfully. Check if we can store
// to the cache for future access. // the thumbnail to the cache for future access.
QSaveFile thumbnailfile(thumbPath.absoluteFilePath(thumbName)); #if KIO_VERSION >= QT_VERSION_CHECK(5, 83, 0)
if (thumbnailfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { if (metaData("cache").toInt()) {
QFileInfo fi(filePath); #else
thumbnail.setText(QStringLiteral("Thumb::URI"), QString::fromUtf8(fileUrl)); {
thumbnail.setText(QStringLiteral("Thumb::MTime"), QString::number(fi.lastModified().toSecsSinceEpoch())); #endif
thumbnail.setText(QStringLiteral("Thumb::Size"), QString::number(fi.size())); // Save the cache
QSaveFile thumbnailfile(thumbPath.absoluteFilePath(thumbName));
if (thumbnail.save(&thumbnailfile, "png")) {
thumbnailfile.commit(); if (thumbnailfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
QFileInfo fi(filePath);
thumbnail.setText(QStringLiteral("Thumb::URI"), QString::fromUtf8(fileUrl));
thumbnail.setText(QStringLiteral("Thumb::MTime"), QString::number(fi.lastModified().toSecsSinceEpoch()));
thumbnail.setText(QStringLiteral("Thumb::Size"), QString::number(fi.size()));
if (thumbnail.save(&thumbnailfile, "png")) {
thumbnailfile.commit();
}
} }
} }
} else { } else {
return false; return false;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment