From aab3d8866e7a04e84530c6088e556e849717f416 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Tue, 24 Dec 2024 21:32:49 -0600 Subject: [PATCH] refactor --- .../librepertory/src/file_manager/file_manager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/repertory/librepertory/src/file_manager/file_manager.cpp b/repertory/librepertory/src/file_manager/file_manager.cpp index 49deec24..7a988da2 100644 --- a/repertory/librepertory/src/file_manager/file_manager.cpp +++ b/repertory/librepertory/src/file_manager/file_manager.cpp @@ -186,14 +186,17 @@ auto file_manager::evict_file(const std::string &api_path) -> bool { if (open_file_lookup_.contains(api_path)) { closeable_file = open_file_lookup_.at(api_path); } + open_file_lookup_.erase(api_path); - open_lock.unlock(); auto allocated = closeable_file ? closeable_file->get_allocated() : true; - closeable_file.reset(); auto removed = remove_source_and_shrink_cache(api_path, source_path, fsi.size, allocated); + open_lock.unlock(); + + closeable_file.reset(); + if (removed) { event_system::instance().raise(api_path, source_path); @@ -558,15 +561,13 @@ auto file_manager::remove_file(const std::string &api_path) -> api_error { upload_notify_.notify_all(); upload_lock.unlock(); - unique_recur_mutex_lock open_lock(open_file_mtx_); + recur_mutex_lock open_lock(open_file_mtx_); res = provider_.remove_file(api_path); if (res != api_error::success) { return res; } - open_lock.unlock(); - remove_source_and_shrink_cache(api_path, fsi.source_path, fsi.size, allocated); return api_error::success;