refactor
This commit is contained in:
parent
cb0dde2a80
commit
8555d31ddf
@ -1242,7 +1242,7 @@ auto fuse_drive::truncate_impl(std::string api_path, off_t size) -> api_error {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
open_file_data ofd = O_RDWR;
|
open_file_data ofd{O_RDWR};
|
||||||
std::uint64_t handle{};
|
std::uint64_t handle{};
|
||||||
std::shared_ptr<i_open_file> open_file;
|
std::shared_ptr<i_open_file> open_file;
|
||||||
if ((res = fm_->open(api_path, false, ofd, handle, open_file)) !=
|
if ((res = fm_->open(api_path, false, ofd, handle, open_file)) !=
|
||||||
@ -1250,12 +1250,10 @@ auto fuse_drive::truncate_impl(std::string api_path, off_t size) -> api_error {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto cleanup = [this, &handle](const api_error &err) -> api_error {
|
res = open_file->resize(static_cast<std::uint64_t>(size));
|
||||||
fm_->close(handle);
|
fm_->close(handle);
|
||||||
return err;
|
|
||||||
};
|
|
||||||
|
|
||||||
return cleanup(open_file->resize(static_cast<std::uint64_t>(size)));
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_drive::unlink_impl(std::string api_path) -> api_error {
|
auto fuse_drive::unlink_impl(std::string api_path) -> api_error {
|
||||||
|
@ -87,9 +87,9 @@ file_manager::~file_manager() {
|
|||||||
|
|
||||||
void file_manager::close(std::uint64_t handle) {
|
void file_manager::close(std::uint64_t handle) {
|
||||||
unique_recur_mutex_lock file_lock(open_file_mtx_);
|
unique_recur_mutex_lock file_lock(open_file_mtx_);
|
||||||
auto it = open_handle_lookup_.find(handle);
|
auto iter = open_handle_lookup_.find(handle);
|
||||||
if (it != open_handle_lookup_.end()) {
|
if (iter != open_handle_lookup_.end()) {
|
||||||
auto *cur_file = it->second;
|
auto *cur_file = iter->second;
|
||||||
open_handle_lookup_.erase(handle);
|
open_handle_lookup_.erase(handle);
|
||||||
cur_file->remove(handle);
|
cur_file->remove(handle);
|
||||||
|
|
||||||
@ -109,9 +109,9 @@ void file_manager::close(std::uint64_t handle) {
|
|||||||
void file_manager::close_all(const std::string &api_path) {
|
void file_manager::close_all(const std::string &api_path) {
|
||||||
recur_mutex_lock file_lock(open_file_mtx_);
|
recur_mutex_lock file_lock(open_file_mtx_);
|
||||||
std::vector<std::uint64_t> handles;
|
std::vector<std::uint64_t> handles;
|
||||||
auto it = open_file_lookup_.find(api_path);
|
auto iter = open_file_lookup_.find(api_path);
|
||||||
if (it != open_file_lookup_.end()) {
|
if (iter != open_file_lookup_.end()) {
|
||||||
handles = it->second->get_handles();
|
handles = iter->second->get_handles();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &handle : handles) {
|
for (auto &handle : handles) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user