diff --git a/thumbnail/thumbnail.cpp b/thumbnail/thumbnail.cpp --- a/thumbnail/thumbnail.cpp +++ b/thumbnail/thumbnail.cpp @@ -77,6 +77,7 @@ #endif #include "imagefilter.h" +#include // Recognized metadata entries: // mimeType - the mime type of the file, used for the overlay icon if any @@ -721,7 +722,20 @@ } if (!thumbnail.load(thumbPath.absoluteFilePath(thumbName))) { // no cached version is available, a new thumbnail must be created - + + const auto mountsList = KMountPoint::currentMountPoints(); + QString thumbRoot = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/thumbnails/"); + KMountPoint::List encryptedMountsList; + const auto thumbRootMount = mountsList.findByPath(thumbRoot); + std::copy_if(mountsList.begin(), mountsList.end(), + std::back_inserter(encryptedMountsList), + [&thumbRootMount] (KMountPoint::Ptr mount) { + return (thumbRootMount != mount) && + (mount->mountType() == QLatin1String("fuse.cryfs") || + mount->mountType() == QLatin1String("fuse.encfs")); + }); + bool isEncrypted = encryptedMountsList.findByPath(filePath); + QSaveFile thumbnailfile(thumbPath.absoluteFilePath(thumbName)); bool savedCorrectly = false; if (subCreator->create(filePath, cacheSize, cacheSize, thumbnail)) { @@ -729,7 +743,7 @@ // The thumbnail has been created successfully. Store the thumbnail // to the cache for future access. - if (thumbnailfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { + if (!isEncrypted && thumbnailfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { savedCorrectly = thumbnail.save(&thumbnailfile, "PNG"); } } else {