This commit is contained in:
2024-12-24 21:27:43 -06:00
parent b9060328fc
commit 0c31cc217f
2 changed files with 8 additions and 5 deletions

View File

@ -68,7 +68,7 @@ private:
std::unique_ptr<std::thread> upload_thread_; std::unique_ptr<std::thread> upload_thread_;
private: private:
void close_all(const std::string &api_path); [[nodiscard]] auto close_all(const std::string &api_path) -> bool;
void close_timed_out_files(); void close_timed_out_files();

View File

@ -75,13 +75,13 @@ void file_manager::close(std::uint64_t handle) {
closeable_file->remove(handle); closeable_file->remove(handle);
} }
void file_manager::close_all(const std::string &api_path) { auto file_manager::close_all(const std::string &api_path) -> bool {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
unique_recur_mutex_lock file_lock(open_file_mtx_); unique_recur_mutex_lock file_lock(open_file_mtx_);
auto file_iter = open_file_lookup_.find(api_path); auto file_iter = open_file_lookup_.find(api_path);
if (file_iter == open_file_lookup_.end()) { if (file_iter == open_file_lookup_.end()) {
return; return false;
} }
auto closeable_file = file_iter->second; auto closeable_file = file_iter->second;
@ -90,6 +90,8 @@ void file_manager::close_all(const std::string &api_path) {
closeable_file->remove_all(); closeable_file->remove_all();
closeable_file->close(); closeable_file->close();
return closeable_file->get_allocated();
} }
void file_manager::close_timed_out_files() { void file_manager::close_timed_out_files() {
@ -548,7 +550,7 @@ auto file_manager::remove_file(const std::string &api_path) -> api_error {
return res; return res;
} }
close_all(api_path); auto allocated = close_all(api_path);
unique_mutex_lock upload_lock(upload_mtx_); unique_mutex_lock upload_lock(upload_mtx_);
remove_upload(api_path, true); remove_upload(api_path, true);
@ -563,7 +565,8 @@ auto file_manager::remove_file(const std::string &api_path) -> api_error {
return res; return res;
} }
remove_source_and_shrink_cache(api_path, fsi.source_path, fsi.size, true); remove_source_and_shrink_cache(api_path, fsi.source_path, fsi.size,
allocated);
return api_error::success; return api_error::success;
} }