diff options
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/Storages/VCardFileStorage.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Swift/Controllers/Storages/VCardFileStorage.cpp b/Swift/Controllers/Storages/VCardFileStorage.cpp index 5f657a4..3dff06f 100644 --- a/Swift/Controllers/Storages/VCardFileStorage.cpp +++ b/Swift/Controllers/Storages/VCardFileStorage.cpp @@ -55,21 +55,27 @@ boost::shared_ptr<VCard> VCardFileStorage::getVCard(const JID& jid) const { return VCardPersister().loadPayloadGeneric(getVCardPath(jid)); } 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 { - std::string file(jid.toString()); - String::replaceAll(file, '/', "%2f"); - return boost::filesystem::path(vcardsPath / (file + ".xml")); + try { + std::string file(jid.toString()); + String::replaceAll(file, '/', "%2f"); + return boost::filesystem::path(vcardsPath / (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); |