1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 04:04:16 +00:00

* Addressbook: don't save to disk if address map is empty

This commit is contained in:
hagen 2016-02-11 00:00:00 +00:00
parent d8ea3a9035
commit 2f2b12811f

View File

@ -161,6 +161,11 @@ namespace client
int AddressBookFilesystemStorage::Save (const std::map<std::string, i2p::data::IdentHash>& addresses) int AddressBookFilesystemStorage::Save (const std::map<std::string, i2p::data::IdentHash>& addresses)
{ {
if (addresses.size() == 0) {
LogPrint(eLogWarning, "Addressbook: not saving empty addressbook");
return 0;
}
int num = 0; int num = 0;
auto filename = GetPath () / "addresses.csv"; auto filename = GetPath () / "addresses.csv";
std::ofstream f (filename.string (), std::ofstream::out); // in text mode std::ofstream f (filename.string (), std::ofstream::out); // in text mode