Added Cache's to retroshare configuration.

* Completed CacheConfig serialisation.
* Switched to Push Cache Mode (faster and more efficient).
* Added CancelCacheTransfer() if we have duplicate HASH / CACHEID.
* Store remote and local caches.
* cleanup all cache directories.
* Broke Cache tests :(  - because of dependency of mAuthMgr/mConnMgr.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@343 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-02-09 12:47:45 +00:00
parent 1bb4283986
commit 276a6bbd99
21 changed files with 796 additions and 352 deletions

View file

@ -42,11 +42,11 @@ std::string generateRandomLinkId();
#define RANK_DEBUG 1
p3Ranking::p3Ranking(uint16_t type, CacheTransfer *cft,
p3Ranking::p3Ranking(uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
std::string sourcedir, std::string storedir,
uint32_t storePeriod)
:CacheSource(type, true, sourcedir),
CacheStore(type, true, cft, storedir),
:CacheSource(type, true, cs, sourcedir),
CacheStore(type, true, cs, cft, storedir),
mStorePeriod(storePeriod)
{
@ -64,7 +64,35 @@ p3Ranking::p3Ranking(uint16_t type, CacheTransfer *cft,
bool p3Ranking::loadLocalCache(const CacheData &data)
{
/* ignore Local Cache -> just use remote caches */
std::string filename = data.path + '/' + data.name;
std::string hash = data.hash;
//uint64_t size = data.size;
std::string source = data.pid;
#ifdef RANK_DEBUG
std::cerr << "p3Ranking::loadLocalCache()";
std::cerr << std::endl;
std::cerr << "\tSource: " << source;
std::cerr << std::endl;
std::cerr << "\tFilename: " << filename;
std::cerr << std::endl;
std::cerr << "\tHash: " << hash;
std::cerr << std::endl;
std::cerr << "\tSize: " << data.size;
std::cerr << std::endl;
#endif
loadRankFile(filename, source);
{
RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/
mRepublish = false;
}
if (data.size > 0) /* don't refresh zero sized caches */
{
refreshCache(data);
}
return true;
}
@ -90,6 +118,11 @@ int p3Ranking::loadCache(const CacheData &data)
loadRankFile(filename, source);
CacheStore::lockData(); /***** LOCK ****/
locked_storeCacheEntry(data);
CacheStore::unlockData(); /***** UNLOCK ****/
return 1;
}

View file

@ -65,7 +65,7 @@ class p3Ranking: public CacheSource, public CacheStore
{
public:
p3Ranking(uint16_t type, CacheTransfer *cft,
p3Ranking(uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
std::string sourcedir, std::string storedir,
uint32_t storePeriod);