mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
added a checkbox in settings for tuning auto-check of shared directories
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4107 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5492f405c3
commit
7c6682b89f
10 changed files with 151 additions and 23 deletions
|
@ -161,6 +161,16 @@ bool ftFiMonitor::search(const std::string &hash, uint32_t hintflags, FileInfo &
|
|||
return false;
|
||||
};
|
||||
|
||||
int ftFiMonitor::watchPeriod() const
|
||||
{
|
||||
return getPeriod() ;
|
||||
}
|
||||
void ftFiMonitor::setWatchPeriod(int seconds)
|
||||
{
|
||||
setPeriod(seconds) ;// call FileIndexMonitor
|
||||
IndicateConfigChanged() ;
|
||||
}
|
||||
|
||||
void ftFiMonitor::setRememberHashCacheDuration(uint32_t days)
|
||||
{
|
||||
setRememberHashFilesDuration(days) ; // calls FileIndexMonitor
|
||||
|
@ -204,6 +214,7 @@ RsSerialiser *ftFiMonitor::setupSerialiser()
|
|||
|
||||
const std::string hash_cache_duration_ss("HASH_CACHE_DURATION");
|
||||
const std::string hash_cache_ss("HASH_CACHE");
|
||||
const std::string watch_file_duration_ss("WATCH_FILES_DELAY");
|
||||
|
||||
bool ftFiMonitor::saveList(bool &cleanup, std::list<RsItem *>& sList)
|
||||
{
|
||||
|
@ -235,12 +246,21 @@ bool ftFiMonitor::saveList(bool &cleanup, std::list<RsItem *>& sList)
|
|||
std::map<std::string, std::string> configMap;
|
||||
|
||||
/* basic control parameters */
|
||||
std::ostringstream s ;
|
||||
s << rememberHashFilesDuration() ;
|
||||
{
|
||||
std::ostringstream s ;
|
||||
s << rememberHashFilesDuration() ;
|
||||
|
||||
configMap[hash_cache_duration_ss] = s.str() ;
|
||||
configMap[hash_cache_duration_ss] = s.str() ;
|
||||
}
|
||||
configMap[hash_cache_ss] = rememberHashFiles()?"YES":"NO" ;
|
||||
|
||||
{
|
||||
std::ostringstream s ;
|
||||
s << watchPeriod() ;
|
||||
|
||||
configMap[watch_file_duration_ss] = s.str() ;
|
||||
}
|
||||
|
||||
RsConfigKeyValueSet *rskv = new RsConfigKeyValueSet();
|
||||
|
||||
/* Convert to TLV */
|
||||
|
@ -297,6 +317,13 @@ bool ftFiMonitor::loadList(std::list<RsItem *>& load)
|
|||
}
|
||||
if(configMap.end() != (mit = configMap.find(hash_cache_ss)))
|
||||
setRememberHashFiles( mit->second == "YES") ;
|
||||
|
||||
if(configMap.end() != (mit = configMap.find(watch_file_duration_ss)))
|
||||
{
|
||||
uint32_t t=0 ;
|
||||
if(sscanf(mit->second.c_str(),"%d",&t) == 1)
|
||||
setWatchPeriod(t);
|
||||
}
|
||||
}
|
||||
|
||||
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it);
|
||||
|
|
|
@ -71,6 +71,8 @@ class ftFiMonitor: public FileIndexMonitor, public ftSearch, public p3Config
|
|||
void setRememberHashCache(bool) ;
|
||||
bool rememberHashCache() ;
|
||||
void clearHashCache() ;
|
||||
void setWatchPeriod(int seconds) ; // can be negative, which means auto-check disabled.
|
||||
int watchPeriod() const ;
|
||||
|
||||
/***
|
||||
* Configuration - store shared directories
|
||||
|
|
|
@ -167,9 +167,8 @@ void ftServer::StartupThreads()
|
|||
|
||||
/* startup Monitor Thread */
|
||||
/* startup the FileMonitor (after cache load) */
|
||||
mFiMon->setPeriod(600); /* 10 minutes */
|
||||
/* start it up */
|
||||
//mFiMon->setSharedDirectories(dbase_dirs);
|
||||
|
||||
mFiMon->start();
|
||||
|
||||
/* Controller thread */
|
||||
|
@ -644,6 +643,15 @@ bool ftServer::removeSharedDirectory(std::string dir)
|
|||
|
||||
return true;
|
||||
}
|
||||
void ftServer::setWatchPeriod(int minutes)
|
||||
{
|
||||
mFiMon->setWatchPeriod(minutes*60) ;
|
||||
}
|
||||
int ftServer::watchPeriod() const
|
||||
{
|
||||
return mFiMon->watchPeriod()/60 ;
|
||||
}
|
||||
|
||||
void ftServer::setRememberHashFiles(bool b)
|
||||
{
|
||||
mFiMon->setRememberHashCache(b) ;
|
||||
|
|
|
@ -205,6 +205,8 @@ virtual bool shareDownloadDirectory(bool share);
|
|||
virtual bool rememberHashFiles() const ;
|
||||
virtual void setRememberHashFiles(bool) ;
|
||||
virtual void clearHashCache() ;
|
||||
virtual void setWatchPeriod(int minutes) ;
|
||||
virtual int watchPeriod() const ;
|
||||
|
||||
/***************************************************************/
|
||||
/*************** Control Interface *****************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue