added full re-scan when symbolic links are (des)activated, since the directory time stamps will not trigger an update

This commit is contained in:
mr-alice 2016-11-25 20:50:10 +01:00
parent 3f3efca22d
commit 2953957e66
2 changed files with 12 additions and 2 deletions

View file

@ -44,6 +44,7 @@ LocalDirectoryUpdater::LocalDirectoryUpdater(HashStorage *hc,LocalDirectoryStora
mDelayBetweenDirectoryUpdates = DELAY_BETWEEN_DIRECTORY_UPDATES; mDelayBetweenDirectoryUpdates = DELAY_BETWEEN_DIRECTORY_UPDATES;
mIsEnabled = false ; mIsEnabled = false ;
mFollowSymLinks = FOLLOW_SYMLINKS_DEFAULT ; mFollowSymLinks = FOLLOW_SYMLINKS_DEFAULT ;
mNeedsFullRebuild = false ;
} }
bool LocalDirectoryUpdater::isEnabled() const bool LocalDirectoryUpdater::isEnabled() const
@ -70,6 +71,8 @@ void LocalDirectoryUpdater::data_tick()
if(now > mDelayBetweenDirectoryUpdates + mLastSweepTime) if(now > mDelayBetweenDirectoryUpdates + mLastSweepTime)
{ {
sweepSharedDirectories() ; sweepSharedDirectories() ;
mNeedsFullRebuild = false ;
mLastSweepTime = now; mLastSweepTime = now;
mSharedDirectories->notifyTSChanged() ; mSharedDirectories->notifyTSChanged() ;
} }
@ -131,6 +134,7 @@ void LocalDirectoryUpdater::sweepSharedDirectories()
recursUpdateSharedDir(stored_dir_it.name(), *stored_dir_it,existing_dirs) ; // here we need to use the list that was stored, instead of the shared dir list, because the two recursUpdateSharedDir(stored_dir_it.name(), *stored_dir_it,existing_dirs) ; // here we need to use the list that was stored, instead of the shared dir list, because the two
// are not necessarily in the same order. // are not necessarily in the same order.
} }
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0); RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
} }
@ -164,8 +168,8 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
return; return;
} }
if(dirIt.dir_modtime() > dir_local_mod_time) // the > is because we may have changed the virtual name, and therefore the TS wont match. if(mNeedsFullRebuild || dirIt.dir_modtime() > dir_local_mod_time) // the > is because we may have changed the virtual name, and therefore the TS wont match.
// we only want to detect when the directory has changed on the disk // we only want to detect when the directory has changed on the disk
{ {
// collect subdirs and subfiles // collect subdirs and subfiles
@ -260,7 +264,12 @@ uint32_t LocalDirectoryUpdater::fileWatchPeriod() const
void LocalDirectoryUpdater::setFollowSymLinks(bool b) void LocalDirectoryUpdater::setFollowSymLinks(bool b)
{ {
if(b != mFollowSymLinks)
mNeedsFullRebuild = true ;
mFollowSymLinks = b ; mFollowSymLinks = b ;
forceUpdate();
} }
bool LocalDirectoryUpdater::followSymLinks() const bool LocalDirectoryUpdater::followSymLinks() const

View file

@ -74,5 +74,6 @@ private:
uint32_t mDelayBetweenDirectoryUpdates; uint32_t mDelayBetweenDirectoryUpdates;
bool mIsEnabled ; bool mIsEnabled ;
bool mFollowSymLinks; bool mFollowSymLinks;
bool mNeedsFullRebuild ;
}; };