summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-04-23 11:03:56 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-04-23 11:03:56 (GMT)
commit39d46fb62ef01c3394ec0b453229f8d703f75153 (patch)
treef1b99fe5e337b90182539326a78f8967a010c9db /Swiften
parentc5dc30ae9ad8b9f3b0209c8ba177f1ce170a6364 (diff)
downloadswift-39d46fb62ef01c3394ec0b453229f8d703f75153.zip
swift-39d46fb62ef01c3394ec0b453229f8d703f75153.tar.bz2
Fixed assertion with inconsitent vcard cache.
Resolves: #1077
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Avatars/VCardAvatarManager.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Swiften/Avatars/VCardAvatarManager.cpp b/Swiften/Avatars/VCardAvatarManager.cpp
index c9571c3..ef1d293 100644
--- a/Swiften/Avatars/VCardAvatarManager.cpp
+++ b/Swiften/Avatars/VCardAvatarManager.cpp
@@ -14,6 +14,7 @@
#include <Swiften/Avatars/AvatarStorage.h>
#include <Swiften/MUC/MUCRegistry.h>
#include <Swiften/VCards/VCardManager.h>
+#include <Swiften/Base/Log.h>
namespace Swift {
@@ -35,6 +36,13 @@ std::string VCardAvatarManager::getAvatarHash(const JID& jid) const {
if (!avatarStorage_->hasAvatar(hash)) {
VCard::ref vCard = vcardManager_->getVCard(avatarJID);
if (vCard) {
+ std::string newHash = Hexify::hexify(SHA1::getHash(vCard->getPhoto()));
+ if (newHash != hash) {
+ // Shouldn't happen, but sometimes seem to. Might be fixed if we
+ // move to a safer backend.
+ SWIFT_LOG(warning) << "Inconsistent vCard photo hash cache";
+ hash = newHash;
+ }
avatarStorage_->addAvatar(hash, vCard->getPhoto());
}
else {