mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-11 17:04:31 -05:00
Merged
- trunk commit 3204:cachestrapper checks for physical presence of own cache files if they don't exist they are not saved p3distrib: don't refresh cache if file not written successfully - trunk commit 3205:still have to clean pending pub msgs and pointer deleted when sent. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@3208 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f28792c1d5
commit
a00e311dd6
@ -699,7 +699,18 @@ bool CacheStrapper::findCache(std::string hash, CacheData &data) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CacheStrapper::CacheExist(CacheData& data){
|
||||||
|
|
||||||
|
std::string filename = data.path + "/" + data.name;
|
||||||
|
FILE* file = NULL;
|
||||||
|
file = fopen(filename.c_str(), "r");
|
||||||
|
|
||||||
|
if(file == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
fclose(file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/****************************** CONFIGURATION HANDLING *********************/
|
/****************************** CONFIGURATION HANDLING *********************/
|
||||||
@ -746,7 +757,8 @@ std::list<RsItem *> CacheStrapper::saveList(bool &cleanup)
|
|||||||
|
|
||||||
for(tit = ownTmp.begin(); tit != ownTmp.end(); tit++)
|
for(tit = ownTmp.begin(); tit != ownTmp.end(); tit++)
|
||||||
{
|
{
|
||||||
ownCaches.push_back(tit->second);
|
if(CacheExist(tit->second))
|
||||||
|
ownCaches.push_back(tit->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,6 +303,12 @@ bool findCache(std::string hash, CacheData &data) const;
|
|||||||
void listCaches(std::ostream &out);
|
void listCaches(std::ostream &out);
|
||||||
void listPeerStatus(std::ostream &out);
|
void listPeerStatus(std::ostream &out);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the cache physically exist at path given
|
||||||
|
* @param data
|
||||||
|
* @return whether it exists or not
|
||||||
|
*/
|
||||||
|
bool CacheExist(CacheData& data);
|
||||||
|
|
||||||
/* Config */
|
/* Config */
|
||||||
protected:
|
protected:
|
||||||
|
@ -734,6 +734,8 @@ void p3GroupDistrib::locked_publishPendingMsgs()
|
|||||||
CacheData newCache;
|
CacheData newCache;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
|
bool ok = true; // hass msg/cache file been written successfully
|
||||||
|
|
||||||
newCache.pid = mOwnId;
|
newCache.pid = mOwnId;
|
||||||
newCache.cid.type = CacheSource::getCacheType();
|
newCache.cid.type = CacheSource::getCacheType();
|
||||||
newCache.cid.subid = locked_determineCacheSubId();
|
newCache.cid.subid = locked_determineCacheSubId();
|
||||||
@ -770,7 +772,10 @@ void p3GroupDistrib::locked_publishPendingMsgs()
|
|||||||
resave = true;
|
resave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
store->SendItem(*it); /* deletes it */
|
if(!store->SendItem(*it)) /* deletes it */
|
||||||
|
{
|
||||||
|
ok &= false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extract File Information from pqistore */
|
/* Extract File Information from pqistore */
|
||||||
@ -788,6 +793,7 @@ void p3GroupDistrib::locked_publishPendingMsgs()
|
|||||||
if(!RsDirUtil::renameFile(filenametmp,filename))
|
if(!RsDirUtil::renameFile(filenametmp,filename))
|
||||||
{
|
{
|
||||||
std::ostringstream errlog;
|
std::ostringstream errlog;
|
||||||
|
ok &= false;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
errlog << "Error " << GetLastError() ;
|
errlog << "Error " << GetLastError() ;
|
||||||
#else
|
#else
|
||||||
@ -800,9 +806,12 @@ void p3GroupDistrib::locked_publishPendingMsgs()
|
|||||||
mLastPublishTime = now;
|
mLastPublishTime = now;
|
||||||
|
|
||||||
/* push file to CacheSource */
|
/* push file to CacheSource */
|
||||||
refreshCache(newCache);
|
|
||||||
|
|
||||||
if (resave)
|
if(ok)
|
||||||
|
refreshCache(newCache);
|
||||||
|
|
||||||
|
|
||||||
|
if (ok && resave)
|
||||||
{
|
{
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::locked_publishPendingMsgs() Indicate Save Data Changed";
|
std::cerr << "p3GroupDistrib::locked_publishPendingMsgs() Indicate Save Data Changed";
|
||||||
|
Loading…
Reference in New Issue
Block a user