summaryrefslogtreecommitdiffstats
path: root/src/library/coverart.cpp
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2020-02-28 14:10:42 +0100
committerUwe Klotz <uklotz@mixxx.org>2020-02-28 15:16:58 +0100
commit3af36447bc990423bf1366799b944baff17b4918 (patch)
tree50063087d1cb62bd2c18250bc9aeb14470d8bb6e /src/library/coverart.cpp
parent60b03bcb97c1c10af6871dccad29d1e6e37a00ff (diff)
Prepare CoverArtCache for migration to new hash function
Diffstat (limited to 'src/library/coverart.cpp')
-rw-r--r--src/library/coverart.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/library/coverart.cpp b/src/library/coverart.cpp
index 27f317d6ba..3b43890ceb 100644
--- a/src/library/coverart.cpp
+++ b/src/library/coverart.cpp
@@ -137,6 +137,32 @@ QImage CoverInfo::loadImage(
}
}
+bool CoverInfo::refreshImageHash(
+ const QImage& loadedImage,
+ const SecurityTokenPointer& pTrackLocationToken) {
+ if (CoverImageUtils::isValidHash(hash)) {
+ // Trust that a valid hash has been calculated from the
+ // corresponding image. Otherwise we would refresh all
+ // hashes over and over again.
+ return false;
+ }
+ QImage image = loadedImage;
+ if (loadedImage.isNull()) {
+ image = loadImage(pTrackLocationToken);
+ }
+ if (image.isNull() && type != CoverInfo::NONE) {
+ kLogger.warning()
+ << "Resetting cover info"
+ << *this;
+ reset();
+ return true;
+ }
+ hash = CoverImageUtils::calculateHash(image);
+ DEBUG_ASSERT(image.isNull() || CoverImageUtils::isValidHash(hash));
+ DEBUG_ASSERT(!image.isNull() || hash == CoverImageUtils::defaultHash());
+ return true;
+}
+
bool operator==(const CoverInfo& a, const CoverInfo& b) {
return static_cast<const CoverInfoRelative&>(a) ==
static_cast<const CoverInfoRelative&>(b) &&