Fixed the Missing Cache File bug.

* Added Old Cache Storage... so these can be retrieved.
 * Connected up the CancelCacheFile() -> FileCancel.

Other Changes.
 * Removed ipaddr = 1 bug (thought someone else had commited this earlier???)
 * added #ifdefs to remove debugging output in p3BitDht.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4330 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2011-06-24 15:10:52 +00:00
parent ee278b45b7
commit a333b12618
5 changed files with 97 additions and 13 deletions

View file

@ -99,14 +99,21 @@ bool CacheSource::refreshCache(const CacheData &data)
bool ret = false;
if (data.cid.type == getCacheType())
{
int subid = 0;
if (isMultiCache())
{
caches[data.cid.subid] = data;
subid = data.cid.subid;
}
else
/* Backup the old Caches */
CacheSet::const_iterator it;
if (caches.end() != (it = caches.find(subid)))
{
caches[0] = data;
mOldCaches[it->second.hash] = it->second;
}
/* store new cache */
caches[subid] = data;
ret = true;
}
@ -127,6 +134,8 @@ bool CacheSource::clearCache(CacheId id)
CacheSet::iterator it;
if (caches.end() != (it = caches.find(id.subid)))
{
/* Backup the old Caches */
mOldCaches[it->second.hash] = it->second;
caches.erase(it);
ret = true;
}
@ -170,6 +179,17 @@ bool CacheSource::findCache(std::string hash, CacheData &data) const
}
}
if (!found)
{
std::map<std::string, CacheData>::const_iterator oit;
oit = mOldCaches.find(hash);
if (oit != mOldCaches.end())
{
data = oit->second;
found = true;
}
}
unlockData(); /* UNLOCK MUTEX */
return found;
@ -384,6 +404,7 @@ void CacheStore::availableCache(const CacheData &data)
}
/* called when the download is completed ... updates internal data */
void CacheStore::downloadedCache(const CacheData &data)
{
@ -404,6 +425,7 @@ void CacheStore::failedCache(const CacheData &data)
#ifdef CS_DEBUG
std::cerr << "CacheStore::failedCache() :" << data << std::endl;
#endif
return;
}

View file

@ -206,7 +206,8 @@ class CacheSource
void lockData() const;
void unlockData() const;
CacheSet caches; /// all cache data local and remote stored here
CacheSet caches; /// all local cache data stored here
std::map<std::string, CacheData> mOldCaches; /// replaced/cleared caches are pushed here (in case requested)
private: