diff --git a/repertory/librepertory/src/file_manager/cache_size_mgr.cpp b/repertory/librepertory/src/file_manager/cache_size_mgr.cpp index 32d80059..f1fe7bf3 100644 --- a/repertory/librepertory/src/file_manager/cache_size_mgr.cpp +++ b/repertory/librepertory/src/file_manager/cache_size_mgr.cpp @@ -91,11 +91,12 @@ void cache_size_mgr::initialize(app_config *cfg) { } auto cache_size_mgr::shrink(std::uint64_t size) -> api_error { + mutex_lock lock(mtx_); if (size == 0U) { + notify_.notify_all(); return api_error::success; } - mutex_lock lock(mtx_); if (cache_size_ >= size) { cache_size_ -= size; } else { diff --git a/repertory/librepertory/src/file_manager/file_manager.cpp b/repertory/librepertory/src/file_manager/file_manager.cpp index 74b24883..1f95b5bf 100644 --- a/repertory/librepertory/src/file_manager/file_manager.cpp +++ b/repertory/librepertory/src/file_manager/file_manager.cpp @@ -614,6 +614,12 @@ auto file_manager::remove_source_and_shrink_cache( } if (not allocated || source_size == 0U) { + auto res = cache_size_mgr::instance().shrink(0U); + if (res != api_error::success) { + utils::error::raise_api_path_error(function_name, api_path, source_path, + res, "failed to shrink cache"); + } + return true; }