From 2953957e667e423333f4ed418d3182f921004530 Mon Sep 17 00:00:00 2001 From: mr-alice Date: Fri, 25 Nov 2016 20:50:10 +0100 Subject: [PATCH] added full re-scan when symbolic links are (des)activated, since the directory time stamps will not trigger an update --- libretroshare/src/file_sharing/directory_updater.cc | 13 +++++++++++-- libretroshare/src/file_sharing/directory_updater.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/file_sharing/directory_updater.cc b/libretroshare/src/file_sharing/directory_updater.cc index 21c9a36dc..1fa1b65eb 100644 --- a/libretroshare/src/file_sharing/directory_updater.cc +++ b/libretroshare/src/file_sharing/directory_updater.cc @@ -44,6 +44,7 @@ LocalDirectoryUpdater::LocalDirectoryUpdater(HashStorage *hc,LocalDirectoryStora mDelayBetweenDirectoryUpdates = DELAY_BETWEEN_DIRECTORY_UPDATES; mIsEnabled = false ; mFollowSymLinks = FOLLOW_SYMLINKS_DEFAULT ; + mNeedsFullRebuild = false ; } bool LocalDirectoryUpdater::isEnabled() const @@ -70,6 +71,8 @@ void LocalDirectoryUpdater::data_tick() if(now > mDelayBetweenDirectoryUpdates + mLastSweepTime) { sweepSharedDirectories() ; + + mNeedsFullRebuild = false ; mLastSweepTime = now; 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 // are not necessarily in the same order. } + RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0); } @@ -164,8 +168,8 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p 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. - // we only want to detect when the directory has changed on the disk + 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 { // collect subdirs and subfiles @@ -260,7 +264,12 @@ uint32_t LocalDirectoryUpdater::fileWatchPeriod() const void LocalDirectoryUpdater::setFollowSymLinks(bool b) { + if(b != mFollowSymLinks) + mNeedsFullRebuild = true ; + mFollowSymLinks = b ; + + forceUpdate(); } bool LocalDirectoryUpdater::followSymLinks() const diff --git a/libretroshare/src/file_sharing/directory_updater.h b/libretroshare/src/file_sharing/directory_updater.h index 61c5a66da..907d18cd3 100644 --- a/libretroshare/src/file_sharing/directory_updater.h +++ b/libretroshare/src/file_sharing/directory_updater.h @@ -74,5 +74,6 @@ private: uint32_t mDelayBetweenDirectoryUpdates; bool mIsEnabled ; bool mFollowSymLinks; + bool mNeedsFullRebuild ; };