fixed force check directories when auto check is disabled

This commit is contained in:
csoler 2017-03-02 23:18:12 +01:00
parent cdb0c6e59e
commit 303bc09739
2 changed files with 13 additions and 3 deletions

View File

@ -48,6 +48,8 @@ LocalDirectoryUpdater::LocalDirectoryUpdater(HashStorage *hc,LocalDirectoryStora
// Can be left to false, but setting it to true will force to re-hash any file that has been left unhashed in the last session. // Can be left to false, but setting it to true will force to re-hash any file that has been left unhashed in the last session.
mNeedsFullRecheck = true ; mNeedsFullRecheck = true ;
mIsChecking = false ;
mForceUpdate = false ;
} }
bool LocalDirectoryUpdater::isEnabled() const bool LocalDirectoryUpdater::isEnabled() const
@ -70,9 +72,9 @@ void LocalDirectoryUpdater::setEnabled(bool b)
void LocalDirectoryUpdater::data_tick() void LocalDirectoryUpdater::data_tick()
{ {
time_t now = time(NULL) ; time_t now = time(NULL) ;
if (mIsEnabled)
{
if (mIsEnabled || mForceUpdate)
{
if(now > mDelayBetweenDirectoryUpdates + mLastSweepTime) if(now > mDelayBetweenDirectoryUpdates + mLastSweepTime)
{ {
if(sweepSharedDirectories()) if(sweepSharedDirectories())
@ -80,6 +82,7 @@ void LocalDirectoryUpdater::data_tick()
mNeedsFullRecheck = false; mNeedsFullRecheck = false;
mLastSweepTime = now ; mLastSweepTime = now ;
mSharedDirectories->notifyTSChanged(); mSharedDirectories->notifyTSChanged();
mForceUpdate = false ;
} }
else else
std::cerr << "(WW) sweepSharedDirectories() failed. Will do it again in a short time." << std::endl; std::cerr << "(WW) sweepSharedDirectories() failed. Will do it again in a short time." << std::endl;
@ -97,7 +100,8 @@ void LocalDirectoryUpdater::data_tick()
void LocalDirectoryUpdater::forceUpdate() void LocalDirectoryUpdater::forceUpdate()
{ {
mLastSweepTime = 0; mForceUpdate = true ;
mLastSweepTime = 0 ;
} }
bool LocalDirectoryUpdater::sweepSharedDirectories() bool LocalDirectoryUpdater::sweepSharedDirectories()
@ -108,6 +112,8 @@ bool LocalDirectoryUpdater::sweepSharedDirectories()
return false; return false;
} }
mIsChecking = true ;
RsServer::notify()->notifyListPreChange(NOTIFY_LIST_DIRLIST_LOCAL, 0); RsServer::notify()->notifyListPreChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
#ifdef DEBUG_LOCAL_DIR_UPDATER #ifdef DEBUG_LOCAL_DIR_UPDATER
std::cerr << "[directory storage] LocalDirectoryUpdater::sweep()" << std::endl; std::cerr << "[directory storage] LocalDirectoryUpdater::sweep()" << std::endl;
@ -149,6 +155,8 @@ bool LocalDirectoryUpdater::sweepSharedDirectories()
} }
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0); RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
mIsChecking = false ;
return true ; return true ;
} }

View File

@ -75,5 +75,7 @@ private:
bool mIsEnabled ; bool mIsEnabled ;
bool mFollowSymLinks; bool mFollowSymLinks;
bool mNeedsFullRecheck ; bool mNeedsFullRecheck ;
bool mIsChecking ;
bool mForceUpdate ;
}; };