From eba9a50f10082430c38b849b6af95f92f3de6ef8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Sun, 28 Aug 2011 16:39:42 +0200
Subject: Keep VCard photo hash cache consistent.


diff --git a/Swiften/VCards/VCardFileStorage.cpp b/Swiften/VCards/VCardFileStorage.cpp
index cd5cc9c..476fde1 100644
--- a/Swiften/VCards/VCardFileStorage.cpp
+++ b/Swiften/VCards/VCardFileStorage.cpp
@@ -48,6 +48,7 @@ VCardFileStorage::VCardFileStorage(boost::filesystem::path dir) : vcardsPath(dir
 }
 
 boost::shared_ptr<VCard> VCardFileStorage::getVCard(const JID& jid) const {
+	boost::shared_ptr<VCard> result;
 	try {
 		boost::filesystem::path vcardPath(getVCardPath(jid));
 		if (boost::filesystem::exists(vcardPath)) {
@@ -57,16 +58,14 @@ boost::shared_ptr<VCard> VCardFileStorage::getVCard(const JID& jid) const {
 			VCardParser parser;
 			PayloadParserTester tester(&parser);
 			tester.parse(data.toString());
-			return boost::dynamic_pointer_cast<VCard>(parser.getPayload());
-		}
-		else {
-			return boost::shared_ptr<VCard>();
+			result = boost::dynamic_pointer_cast<VCard>(parser.getPayload());
 		}
 	}
 	catch (const boost::filesystem::filesystem_error& e) {
 		std::cerr << "ERROR: " << e.what() << std::endl;
-		return boost::shared_ptr<VCard>();
 	}
+	getAndUpdatePhotoHash(jid, result);
+	return result;
 }
 
 void VCardFileStorage::setVCard(const JID& jid, VCard::ref v) {
-- 
cgit v0.10.2-6-g49f6