refactor
This commit is contained in:
@ -68,7 +68,7 @@ private:
|
||||
std::unique_ptr<std::thread> upload_thread_;
|
||||
|
||||
private:
|
||||
void close_all(const std::string &api_path);
|
||||
[[nodiscard]] auto close_all(const std::string &api_path) -> bool;
|
||||
|
||||
void close_timed_out_files();
|
||||
|
||||
|
@ -75,13 +75,13 @@ void file_manager::close(std::uint64_t 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();
|
||||
|
||||
unique_recur_mutex_lock file_lock(open_file_mtx_);
|
||||
auto file_iter = open_file_lookup_.find(api_path);
|
||||
if (file_iter == open_file_lookup_.end()) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
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->close();
|
||||
|
||||
return closeable_file->get_allocated();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
close_all(api_path);
|
||||
auto allocated = close_all(api_path);
|
||||
|
||||
unique_mutex_lock upload_lock(upload_mtx_);
|
||||
remove_upload(api_path, true);
|
||||
@ -563,7 +565,8 @@ auto file_manager::remove_file(const std::string &api_path) -> api_error {
|
||||
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user