From 303bc097396060b766eea387777e2d33cfce8d13 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 2 Mar 2017 23:18:12 +0100 Subject: [PATCH] fixed force check directories when auto check is disabled --- .../src/file_sharing/directory_updater.cc | 14 +++++++++++--- libretroshare/src/file_sharing/directory_updater.h | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/file_sharing/directory_updater.cc b/libretroshare/src/file_sharing/directory_updater.cc index 9ea578216..21703cfa2 100644 --- a/libretroshare/src/file_sharing/directory_updater.cc +++ b/libretroshare/src/file_sharing/directory_updater.cc @@ -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. mNeedsFullRecheck = true ; + mIsChecking = false ; + mForceUpdate = false ; } bool LocalDirectoryUpdater::isEnabled() const @@ -70,9 +72,9 @@ void LocalDirectoryUpdater::setEnabled(bool b) void LocalDirectoryUpdater::data_tick() { time_t now = time(NULL) ; - if (mIsEnabled) - { + if (mIsEnabled || mForceUpdate) + { if(now > mDelayBetweenDirectoryUpdates + mLastSweepTime) { if(sweepSharedDirectories()) @@ -80,6 +82,7 @@ void LocalDirectoryUpdater::data_tick() mNeedsFullRecheck = false; mLastSweepTime = now ; mSharedDirectories->notifyTSChanged(); + mForceUpdate = false ; } else 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() { - mLastSweepTime = 0; + mForceUpdate = true ; + mLastSweepTime = 0 ; } bool LocalDirectoryUpdater::sweepSharedDirectories() @@ -108,6 +112,8 @@ bool LocalDirectoryUpdater::sweepSharedDirectories() return false; } + mIsChecking = true ; + RsServer::notify()->notifyListPreChange(NOTIFY_LIST_DIRLIST_LOCAL, 0); #ifdef DEBUG_LOCAL_DIR_UPDATER std::cerr << "[directory storage] LocalDirectoryUpdater::sweep()" << std::endl; @@ -149,6 +155,8 @@ bool LocalDirectoryUpdater::sweepSharedDirectories() } RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0); + mIsChecking = false ; + return true ; } diff --git a/libretroshare/src/file_sharing/directory_updater.h b/libretroshare/src/file_sharing/directory_updater.h index e6351caff..b55d38d9e 100644 --- a/libretroshare/src/file_sharing/directory_updater.h +++ b/libretroshare/src/file_sharing/directory_updater.h @@ -75,5 +75,7 @@ private: bool mIsEnabled ; bool mFollowSymLinks; bool mNeedsFullRecheck ; + bool mIsChecking ; + bool mForceUpdate ; };