[bug] Changes to maximum cache size should be updated live #46
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2025-04-13 19:19:52 -05:00
parent bbd82e3f0f
commit 4b925c15c2
2 changed files with 5 additions and 6 deletions

View File

@ -12,7 +12,7 @@
* \#43 [bug] Directories are not importing properly for Sia * \#43 [bug] Directories are not importing properly for Sia
* \#44 [bug] Windows-to-Linux remote mount ignores `CREATE_NEW` * \#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 * \#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 ### Changes from v2.0.5-rc

View File

@ -26,7 +26,7 @@
#include "events/types/invalid_cache_size.hpp" #include "events/types/invalid_cache_size.hpp"
#include "events/types/max_cache_size_reached.hpp" #include "events/types/max_cache_size_reached.hpp"
#include "types/startup_exception.hpp" #include "types/startup_exception.hpp"
#include "utils/file_utils.hpp" #include "utils/file.hpp"
namespace repertory { namespace repertory {
cache_size_mgr cache_size_mgr::instance_{}; 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_}; auto last_cache_size{cache_size_};
cache_size_ += size; cache_size_ += size;
auto max_cache_size{cfg_->get_max_cache_size_bytes()};
auto cache_dir{ auto cache_dir{
utils::file::directory{cfg_->get_cache_directory()}, 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) { cache_dir.count() > 1U) {
if (last_cache_size != cache_size_) { if (last_cache_size != cache_size_) {
event_system::instance().raise<max_cache_size_reached>( event_system::instance().raise<max_cache_size_reached>(
cache_size_, function_name, max_cache_size); cache_size_, function_name, cfg_->get_max_cache_size_bytes());
last_cache_size = cache_size_; last_cache_size = cache_size_;
} }
notify_.wait_for(lock, cache_wait_secs); notify_.wait_for(lock, cache_wait_secs);