diff options
| author | Richard Maudsley <richard.maudsley@isode.com> | 2014-06-20 09:54:54 (GMT) |
|---|---|---|
| committer | Richard Maudsley <richard.maudsley@isode.com> | 2014-06-20 09:55:41 (GMT) |
| commit | f91647cf9a0df0366342fae2cbcfe9df376379ba (patch) | |
| tree | 54deb2ae99023cbd513a3fc70f92430de9332380 /Swift/Controllers | |
| parent | 0d5c2da5c9d2491db90a65766b0224cd47a0f953 (diff) | |
| download | swift-contrib-f91647cf9a0df0366342fae2cbcfe9df376379ba.zip swift-contrib-f91647cf9a0df0366342fae2cbcfe9df376379ba.tar.bz2 | |
Revert "Fix avatar not being updated when cleared"
This reverts commit be915da04068a412dd63a597192ec3232ad4e1c2.
Change-Id: Ibcfa97f3438c03fae850cdeb1855c61180a3d372
Diffstat (limited to 'Swift/Controllers')
| -rw-r--r-- | Swift/Controllers/Storages/VCardFileStorage.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Swift/Controllers/Storages/VCardFileStorage.cpp b/Swift/Controllers/Storages/VCardFileStorage.cpp index b101ecf..b22e235 100644 --- a/Swift/Controllers/Storages/VCardFileStorage.cpp +++ b/Swift/Controllers/Storages/VCardFileStorage.cpp @@ -56,61 +56,61 @@ boost::shared_ptr<VCard> VCardFileStorage::getVCard(const JID& jid) const { boost::shared_ptr<VCard> result = VCardPersister().loadPayloadGeneric(getVCardPath(jid)); getAndUpdatePhotoHash(jid, result); return result; } void VCardFileStorage::setVCard(const JID& jid, VCard::ref v) { VCardPersister().savePayload(v, getVCardPath(jid)); getAndUpdatePhotoHash(jid, v); } boost::filesystem::path VCardFileStorage::getVCardPath(const JID& jid) const { try { std::string file(jid.toString()); String::replaceAll(file, '/', "%2f"); return boost::filesystem::path(vcardsPath / stringToPath(file + ".xml")); } catch (const boost::filesystem::filesystem_error& e) { std::cerr << "ERROR: " << e.what() << std::endl; return boost::filesystem::path(); } } std::string VCardFileStorage::getPhotoHash(const JID& jid) const { PhotoHashMap::const_iterator i = photoHashes.find(jid); if (i != photoHashes.end()) { return i->second; } else { VCard::ref vCard = getVCard(jid); return getAndUpdatePhotoHash(jid, vCard); } } std::string VCardFileStorage::getAndUpdatePhotoHash(const JID& jid, VCard::ref vCard) const { std::string hash; - if (vCard) { + if (vCard && !vCard->getPhoto().empty()) { hash = Hexify::hexify(crypto->getSHA1Hash(vCard->getPhoto())); } std::pair<PhotoHashMap::iterator, bool> r = photoHashes.insert(std::make_pair(jid, hash)); if (r.second) { savePhotoHashes(); } else if (r.first->second != hash) { r.first->second = hash; savePhotoHashes(); } return hash; } void VCardFileStorage::savePhotoHashes() const { try { boost::filesystem::ofstream file(cacheFile); for (PhotoHashMap::const_iterator i = photoHashes.begin(); i != photoHashes.end(); ++i) { file << i->second << " " << i->first.toString() << std::endl; } file.close(); } catch (...) { std::cerr << "Error writing vcards file" << std::endl; } } |
Swift