mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
[addressbook] reset eTags if addressbook can't be loaded
This commit is contained in:
parent
9e9236badb
commit
42c3c28ea7
@ -7,6 +7,7 @@
|
|||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
@ -45,6 +46,7 @@ namespace client
|
|||||||
|
|
||||||
void SaveEtag (const i2p::data::IdentHash& subsciption, const std::string& etag, const std::string& lastModified);
|
void SaveEtag (const i2p::data::IdentHash& subsciption, const std::string& etag, const std::string& lastModified);
|
||||||
bool GetEtag (const i2p::data::IdentHash& subscription, std::string& etag, std::string& lastModified);
|
bool GetEtag (const i2p::data::IdentHash& subscription, std::string& etag, std::string& lastModified);
|
||||||
|
void ResetEtags ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -218,6 +220,17 @@ namespace client
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddressBookFilesystemStorage::ResetEtags ()
|
||||||
|
{
|
||||||
|
LogPrint (eLogError, "Addressbook: resetting eTags");
|
||||||
|
for (boost::filesystem::directory_iterator it (etagsPath); it != boost::filesystem::directory_iterator (); ++it)
|
||||||
|
{
|
||||||
|
if (!boost::filesystem::is_regular_file (it->status ()))
|
||||||
|
continue;
|
||||||
|
boost::filesystem::remove (it->path ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
AddressBook::AddressBook (): m_Storage(nullptr), m_IsLoaded (false), m_IsDownloading (false),
|
AddressBook::AddressBook (): m_Storage(nullptr), m_IsLoaded (false), m_IsDownloading (false),
|
||||||
m_NumRetries (0), m_DefaultSubscription (nullptr), m_SubscriptionsUpdateTimer (nullptr)
|
m_NumRetries (0), m_DefaultSubscription (nullptr), m_SubscriptionsUpdateTimer (nullptr)
|
||||||
@ -356,6 +369,9 @@ namespace client
|
|||||||
LoadHostsFromStream (f, false);
|
LoadHostsFromStream (f, false);
|
||||||
m_IsLoaded = true;
|
m_IsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset eTags, because we don’t know how old hosts.txt is or can't load addressbook
|
||||||
|
m_Storage->ResetEtags ();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddressBook::LoadHostsFromStream (std::istream& f, bool is_update)
|
bool AddressBook::LoadHostsFromStream (std::istream& f, bool is_update)
|
||||||
|
@ -46,6 +46,7 @@ namespace client
|
|||||||
|
|
||||||
virtual void SaveEtag (const i2p::data::IdentHash& subscription, const std::string& etag, const std::string& lastModified) = 0;
|
virtual void SaveEtag (const i2p::data::IdentHash& subscription, const std::string& etag, const std::string& lastModified) = 0;
|
||||||
virtual bool GetEtag (const i2p::data::IdentHash& subscription, std::string& etag, std::string& lastModified) = 0;
|
virtual bool GetEtag (const i2p::data::IdentHash& subscription, std::string& etag, std::string& lastModified) = 0;
|
||||||
|
virtual void ResetEtags () = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AddressBookSubscription;
|
class AddressBookSubscription;
|
||||||
|
Loading…
Reference in New Issue
Block a user