diff --git a/AddressBook.cpp b/AddressBook.cpp index fe5070f7..3b630a65 100644 --- a/AddressBook.cpp +++ b/AddressBook.cpp @@ -27,21 +27,21 @@ namespace client std::string indexPath; public: - AddressBookFilesystemStorage (); + AddressBookFilesystemStorage (): storage("addressbook", "b", "", "b32") {}; std::shared_ptr GetAddress (const i2p::data::IdentHash& ident) const; void AddAddress (std::shared_ptr address); void RemoveAddress (const i2p::data::IdentHash& ident); + bool Init (); int Load (std::map& addresses); int Save (const std::map& addresses); }; - AddressBookFilesystemStorage::AddressBookFilesystemStorage(): - storage("addressbook", "b", "", "b32") + bool AddressBookFilesystemStorage::Init() { storage.SetPlace(i2p::fs::GetDataDir()); - storage.Init(i2p::data::GetBase32SubstitutionTable(), 32); indexPath = storage.GetRoot() + i2p::fs::dirSep + "addresses.csv"; + return storage.Init(i2p::data::GetBase32SubstitutionTable(), 32); } std::shared_ptr AddressBookFilesystemStorage::GetAddress (const i2p::data::IdentHash& ident) const @@ -159,6 +159,7 @@ namespace client void AddressBook::Start () { + m_Storage->Init(); LoadHosts (); /* try storage, then hosts.txt, then download */ StartSubscriptions (); } diff --git a/AddressBook.h b/AddressBook.h index 9ddce82a..16403e1e 100644 --- a/AddressBook.h +++ b/AddressBook.h @@ -35,6 +35,7 @@ namespace client virtual void AddAddress (std::shared_ptr address) = 0; virtual void RemoveAddress (const i2p::data::IdentHash& ident) = 0; + virtual bool Init () = 0; virtual int Load (std::map& addresses) = 0; virtual int Save (const std::map& addresses) = 0; };