diff options
Diffstat (limited to 'core/imagedownloader.cpp')
-rw-r--r-- | core/imagedownloader.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/core/imagedownloader.cpp b/core/imagedownloader.cpp index 0c72f3381..da5c86b99 100644 --- a/core/imagedownloader.cpp +++ b/core/imagedownloader.cpp @@ -151,8 +151,24 @@ static QImage getThumbnailFromCache(const QString &picture_filename) QString filename = thumbnailFileName(picture_filename); if (filename.isEmpty()) return QImage(); - QFile file(filename); + + if (prefs.auto_recalculate_thumbnails) { + // Check if thumbnails is older than the (local) image file + QString filenameLocal = localFilePath(qPrintable(picture_filename)); + QFileInfo pictureInfo(filenameLocal); + QFileInfo thumbnailInfo(file); + if (pictureInfo.exists() && thumbnailInfo.exists()) { + QDateTime pictureTime = pictureInfo.lastModified(); + QDateTime thumbnailTime = thumbnailInfo.lastModified(); + if (pictureTime.isValid() && thumbnailTime.isValid() && thumbnailTime < pictureTime) { + // Both files exist, have valid timestamps and thumbnail was calculated before picture. + // Return an empty thumbnail to signal recalculation of the thumbnail + return QImage(); + } + } + } + if (!file.open(QIODevice::ReadOnly)) return QImage(); QDataStream stream(&file); |