mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 15:15:15 -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
|
@ -57,6 +57,13 @@ FileIndexMonitor::FileIndexMonitor(CacheStrapper *cs, NotifyBase *cb_in,std::str
|
|||
{
|
||||
updatePeriod = 60;
|
||||
}
|
||||
|
||||
bool FileIndexMonitor::autoCheckEnabled() const
|
||||
{
|
||||
RsStackMutex mtx(fiMutex) ; /* LOCKED DIRS */
|
||||
return updatePeriod > 0 ;
|
||||
}
|
||||
|
||||
bool FileIndexMonitor::rememberHashFiles()
|
||||
{
|
||||
RsStackMutex mtx(fiMutex) ; /* LOCKED DIRS */
|
||||
|
@ -443,51 +450,69 @@ bool FileIndexMonitor::updateCache(const CacheData &data) /* we call this one *
|
|||
}
|
||||
|
||||
|
||||
void FileIndexMonitor::setPeriod(int period)
|
||||
uint32_t FileIndexMonitor::getPeriod() const
|
||||
{
|
||||
//#ifdef FIM_DEBUG
|
||||
std::cerr << "FileIndexMonitor::setPeriod() getting watch period" << std::endl;
|
||||
//#endif
|
||||
RsStackMutex mtx(fiMutex) ; /* LOCKED DIRS */
|
||||
return updatePeriod ;
|
||||
}
|
||||
|
||||
void FileIndexMonitor::setPeriod(uint32_t period)
|
||||
{
|
||||
RsStackMutex mtx(fiMutex) ; /* LOCKED DIRS */
|
||||
updatePeriod = period;
|
||||
//#ifdef FIM_DEBUG
|
||||
std::cerr << "FileIndexMonitor::setPeriod() Setting watch period to " << updatePeriod << std::endl;
|
||||
//#endif
|
||||
}
|
||||
|
||||
void FileIndexMonitor::run()
|
||||
//void FileIndexMonitor::run(std::string& current_job)
|
||||
{
|
||||
updateCycle();
|
||||
if(autoCheckEnabled())
|
||||
updateCycle();
|
||||
|
||||
while(isRunning())
|
||||
{
|
||||
|
||||
for(int i = 0; i < updatePeriod; i++)
|
||||
int i=0 ;
|
||||
for(;;i++)
|
||||
{
|
||||
|
||||
if (isRunning() == false) {
|
||||
if(!isRunning())
|
||||
return;
|
||||
}
|
||||
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
sleep(1);
|
||||
#else
|
||||
Sleep(1000);
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
/* check dirs if they've changed */
|
||||
if (internal_setSharedDirectories())
|
||||
{
|
||||
break;
|
||||
|
||||
{
|
||||
RsStackMutex mtx(fiMutex) ;
|
||||
|
||||
if(i >= abs(updatePeriod))
|
||||
break ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(i < abs(updatePeriod) || autoCheckEnabled())
|
||||
updateCycle();
|
||||
|
||||
#ifdef FIM_DEBUG
|
||||
{
|
||||
RsStackMutex mtx(fiMutex) ;
|
||||
std::cerr <<"*********** FileIndex **************" << std::endl ;
|
||||
fi.printFileIndex(std::cerr) ;
|
||||
std::cerr <<"************** END *****************" << std::endl ;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
}
|
||||
|
||||
updateCycle();
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,6 @@ class FileIndexMonitor: public CacheSource, public RsThread
|
|||
void getSharedDirectories(std::list<SharedDirInfo>& dirs);
|
||||
void updateShareFlags(const SharedDirInfo& info) ;
|
||||
|
||||
void setPeriod(int insecs);
|
||||
void forceDirectoryCheck();
|
||||
bool inDirectoryCheck();
|
||||
|
||||
|
@ -157,6 +156,10 @@ class FileIndexMonitor: public CacheSource, public RsThread
|
|||
bool rememberHashFiles() ;
|
||||
// Remove any memory of formerly hashed files that are not shared anymore
|
||||
void clearHashFiles() ;
|
||||
void setPeriod(uint32_t insecs);
|
||||
uint32_t getPeriod() const;
|
||||
|
||||
bool autoCheckEnabled() const ;
|
||||
|
||||
private:
|
||||
/* the mutex should be locked before calling these 3. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue