From 39d46fb62ef01c3394ec0b453229f8d703f75153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be> Date: Mon, 23 Apr 2012 13:03:56 +0200 Subject: Fixed assertion with inconsitent vcard cache. Resolves: #1077 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 { -- cgit v0.10.2-6-g49f6