From 4b925c15c2cb29e8688d81b96880908bc5f8a24e Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sun, 13 Apr 2025 19:19:52 -0500 Subject: [PATCH] [bug] Changes to maximum cache size should be updated live #46 --- CHANGELOG.md | 2 +- .../librepertory/src/file_manager/cache_size_mgr.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8298f9ec..78a20218 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ * \#43 [bug] Directories are not importing properly for Sia * \#44 [bug] Windows-to-Linux remote mount ignores `CREATE_NEW` * \#45 [bug] Windows-to-Linux remote mount is not handling attempts to remove a non-empty directory properly -* ~~\#46 [bug] Changes to maximum cache size should be updated live~~ +* \#46 [bug] Changes to maximum cache size should be updated live ### Changes from v2.0.5-rc diff --git a/repertory/librepertory/src/file_manager/cache_size_mgr.cpp b/repertory/librepertory/src/file_manager/cache_size_mgr.cpp index b661ecf7..976b2fd8 100644 --- a/repertory/librepertory/src/file_manager/cache_size_mgr.cpp +++ b/repertory/librepertory/src/file_manager/cache_size_mgr.cpp @@ -26,7 +26,7 @@ #include "events/types/invalid_cache_size.hpp" #include "events/types/max_cache_size_reached.hpp" #include "types/startup_exception.hpp" -#include "utils/file_utils.hpp" +#include "utils/file.hpp" namespace repertory { cache_size_mgr cache_size_mgr::instance_{}; @@ -49,16 +49,15 @@ auto cache_size_mgr::expand(std::uint64_t size) -> api_error { auto last_cache_size{cache_size_}; cache_size_ += size; - auto max_cache_size{cfg_->get_max_cache_size_bytes()}; - auto cache_dir{ utils::file::directory{cfg_->get_cache_directory()}, }; - while (not get_stop_requested() && cache_size_ > max_cache_size && + while (not get_stop_requested() && + cache_size_ > cfg_->get_max_cache_size_bytes() && cache_dir.count() > 1U) { if (last_cache_size != cache_size_) { event_system::instance().raise( - cache_size_, function_name, max_cache_size); + cache_size_, function_name, cfg_->get_max_cache_size_bytes()); last_cache_size = cache_size_; } notify_.wait_for(lock, cache_wait_secs);