refactor
This commit is contained in:
@ -118,8 +118,8 @@ auto fuse_base::chflags_(const char *path, uint32_t flags) -> int {
|
|||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
auto fuse_base::chmod_(const char *path, mode_t mode,
|
auto fuse_base::chmod_(const char *path, mode_t mode, struct fuse_file_info *fi)
|
||||||
struct fuse_file_info *fi) -> int {
|
-> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
return instance().execute_callback(
|
||||||
@ -186,7 +186,7 @@ void fuse_base::display_options(
|
|||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
fuse_cmdline_help();
|
fuse_cmdline_help();
|
||||||
#else
|
#else
|
||||||
struct fuse_operations fuse_ops {};
|
struct fuse_operations fuse_ops{};
|
||||||
fuse_main(args.size(),
|
fuse_main(args.size(),
|
||||||
reinterpret_cast<char **>(const_cast<char **>(args.data())),
|
reinterpret_cast<char **>(const_cast<char **>(args.data())),
|
||||||
&fuse_ops, nullptr);
|
&fuse_ops, nullptr);
|
||||||
@ -196,7 +196,7 @@ void fuse_base::display_options(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void fuse_base::display_version_information(std::vector<const char *> args) {
|
void fuse_base::display_version_information(std::vector<const char *> args) {
|
||||||
struct fuse_operations fuse_ops {};
|
struct fuse_operations fuse_ops{};
|
||||||
fuse_main(static_cast<int>(args.size()),
|
fuse_main(static_cast<int>(args.size()),
|
||||||
reinterpret_cast<char **>(const_cast<char **>(args.data())),
|
reinterpret_cast<char **>(const_cast<char **>(args.data())),
|
||||||
&fuse_ops, nullptr);
|
&fuse_ops, nullptr);
|
||||||
@ -334,8 +334,8 @@ auto fuse_base::getxtimes_(const char *path, struct timespec *bkuptime,
|
|||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
auto fuse_base::init_(struct fuse_conn_info *conn,
|
auto fuse_base::init_(struct fuse_conn_info *conn, struct fuse_config *cfg)
|
||||||
struct fuse_config *cfg) -> void * {
|
-> void * {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return execute_void_pointer_callback(function_name, [&]() -> void * {
|
return execute_void_pointer_callback(function_name, [&]() -> void * {
|
||||||
@ -408,7 +408,7 @@ auto fuse_base::mount(std::vector<std::string> args) -> int {
|
|||||||
|
|
||||||
char *mount_location{nullptr};
|
char *mount_location{nullptr};
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
struct fuse_cmdline_opts opts {};
|
struct fuse_cmdline_opts opts{};
|
||||||
fuse_parse_cmdline(&fa, &opts);
|
fuse_parse_cmdline(&fa, &opts);
|
||||||
mount_location = opts.mountpoint;
|
mount_location = opts.mountpoint;
|
||||||
#else
|
#else
|
||||||
@ -477,8 +477,8 @@ auto fuse_base::read_(const char *path, char *buffer, size_t read_size,
|
|||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
auto fuse_base::readdir_(const char *path, void *buf,
|
auto fuse_base::readdir_(const char *path, void *buf,
|
||||||
fuse_fill_dir_t fuse_fill_dir, off_t offset,
|
fuse_fill_dir_t fuse_fill_dir, off_t offset,
|
||||||
struct fuse_file_info *fi,
|
struct fuse_file_info *fi, fuse_readdir_flags flags)
|
||||||
fuse_readdir_flags flags) -> int {
|
-> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
return instance().execute_callback(
|
||||||
@ -510,8 +510,8 @@ auto fuse_base::release_(const char *path, struct fuse_file_info *fi) -> int {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_base::releasedir_(const char *path,
|
auto fuse_base::releasedir_(const char *path, struct fuse_file_info *fi)
|
||||||
struct fuse_file_info *fi) -> int {
|
-> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
return instance().execute_callback(
|
||||||
@ -521,8 +521,8 @@ auto fuse_base::releasedir_(const char *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
auto fuse_base::rename_(const char *from, const char *to,
|
auto fuse_base::rename_(const char *from, const char *to, unsigned int flags)
|
||||||
unsigned int flags) -> int {
|
-> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
return instance().execute_callback(
|
||||||
@ -603,7 +603,7 @@ auto fuse_base::listxattr_(const char *path, char *buffer, size_t size) -> int {
|
|||||||
void fuse_base::notify_fuse_args_parsed(const std::vector<std::string> &args) {
|
void fuse_base::notify_fuse_args_parsed(const std::vector<std::string> &args) {
|
||||||
event_system::instance().raise<fuse_args_parsed>(std::accumulate(
|
event_system::instance().raise<fuse_args_parsed>(std::accumulate(
|
||||||
args.begin(), args.end(), std::string(),
|
args.begin(), args.end(), std::string(),
|
||||||
[](std::string command_line, const auto &arg) {
|
[](auto &&command_line, auto &&arg) -> auto {
|
||||||
command_line += (command_line.empty() ? arg : (" " + std::string(arg)));
|
command_line += (command_line.empty() ? arg : (" " + std::string(arg)));
|
||||||
return command_line;
|
return command_line;
|
||||||
}));
|
}));
|
||||||
@ -765,8 +765,8 @@ auto fuse_base::setattr_x_(const char *path, struct setattr_x *attr) -> int {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_base::setbkuptime_(const char *path,
|
auto fuse_base::setbkuptime_(const char *path, const struct timespec *bkuptime)
|
||||||
const struct timespec *bkuptime) -> int {
|
-> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
return instance().execute_callback(
|
||||||
@ -775,8 +775,8 @@ auto fuse_base::setbkuptime_(const char *path,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_base::setchgtime_(const char *path,
|
auto fuse_base::setchgtime_(const char *path, const struct timespec *chgtime)
|
||||||
const struct timespec *chgtime) -> int {
|
-> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
return instance().execute_callback(
|
||||||
@ -785,8 +785,8 @@ auto fuse_base::setchgtime_(const char *path,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_base::setcrtime_(const char *path,
|
auto fuse_base::setcrtime_(const char *path, const struct timespec *crtime)
|
||||||
const struct timespec *crtime) -> int {
|
-> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
return instance().execute_callback(
|
||||||
|
@ -42,7 +42,7 @@ void remote_open_file_table::close_all(const std::string &client_id) {
|
|||||||
auto compat_handles =
|
auto compat_handles =
|
||||||
std::accumulate(compat_file_lookup_.begin(), compat_file_lookup_.end(),
|
std::accumulate(compat_file_lookup_.begin(), compat_file_lookup_.end(),
|
||||||
std::vector<remote::file_handle>(),
|
std::vector<remote::file_handle>(),
|
||||||
[&client_id](auto &&list, auto &&value) {
|
[&client_id](auto &&list, auto &&value) -> auto {
|
||||||
auto &&op_info = value.second;
|
auto &&op_info = value.second;
|
||||||
if (op_info->client_id == client_id) {
|
if (op_info->client_id == client_id) {
|
||||||
list.insert(list.end(), op_info->handles.begin(),
|
list.insert(list.end(), op_info->handles.begin(),
|
||||||
@ -54,7 +54,7 @@ void remote_open_file_table::close_all(const std::string &client_id) {
|
|||||||
|
|
||||||
auto handles = std::accumulate(
|
auto handles = std::accumulate(
|
||||||
file_lookup_.begin(), file_lookup_.end(), std::vector<native_handle>(),
|
file_lookup_.begin(), file_lookup_.end(), std::vector<native_handle>(),
|
||||||
[&client_id](auto &&list, auto &&value) {
|
[&client_id](auto &&list, auto &&value) -> auto {
|
||||||
auto &&op_info = value.second;
|
auto &&op_info = value.second;
|
||||||
if (op_info->client_id == client_id) {
|
if (op_info->client_id == client_id) {
|
||||||
list.insert(list.end(), op_info->handles.begin(),
|
list.insert(list.end(), op_info->handles.begin(),
|
||||||
@ -161,21 +161,21 @@ auto remote_open_file_table::has_compat_open_info(
|
|||||||
|
|
||||||
void remote_open_file_table::remove_all(const std::string &file_path) {
|
void remote_open_file_table::remove_all(const std::string &file_path) {
|
||||||
unique_recur_mutex_lock lock(file_mutex_);
|
unique_recur_mutex_lock lock(file_mutex_);
|
||||||
auto compat_open_list = std::accumulate(
|
auto compat_open_list =
|
||||||
compat_file_lookup_.begin(), compat_file_lookup_.end(),
|
std::accumulate(compat_file_lookup_.begin(), compat_file_lookup_.end(),
|
||||||
std::vector<remote::file_handle>(),
|
std::vector<remote::file_handle>(),
|
||||||
[&file_path](auto &&list, auto &&kv) -> std::vector<remote::file_handle> {
|
[&file_path](auto &&list, auto &&kv) -> auto {
|
||||||
if (kv.first == file_path) {
|
if (kv.first == file_path) {
|
||||||
auto *op_info = kv.second.get();
|
auto *op_info = kv.second.get();
|
||||||
list.insert(list.end(), op_info->handles.begin(),
|
list.insert(list.end(), op_info->handles.begin(),
|
||||||
op_info->handles.end());
|
op_info->handles.end());
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
});
|
});
|
||||||
|
|
||||||
auto open_list = std::accumulate(
|
auto open_list = std::accumulate(
|
||||||
file_lookup_.begin(), file_lookup_.end(), std::vector<native_handle>(),
|
file_lookup_.begin(), file_lookup_.end(), std::vector<native_handle>(),
|
||||||
[&file_path](auto &&list, auto &&kv) -> std::vector<native_handle> {
|
[&file_path](auto &&list, auto &&kv) -> auto {
|
||||||
if (kv.first == file_path) {
|
if (kv.first == file_path) {
|
||||||
auto *op_info = kv.second.get();
|
auto *op_info = kv.second.get();
|
||||||
list.insert(list.end(), op_info->handles.begin(),
|
list.insert(list.end(), op_info->handles.begin(),
|
||||||
|
@ -150,16 +150,16 @@ auto lock_data::set_mount_state(bool active, const std::string &mount_location,
|
|||||||
(mount_state[mount_id]["Location"].get<std::string>() !=
|
(mount_state[mount_id]["Location"].get<std::string>() !=
|
||||||
mount_location)))) {
|
mount_location)))) {
|
||||||
const auto lines = utils::file::read_file_lines(get_lock_data_file());
|
const auto lines = utils::file::read_file_lines(get_lock_data_file());
|
||||||
const auto txt =
|
const auto txt = std::accumulate(
|
||||||
std::accumulate(lines.begin(), lines.end(), std::string(),
|
lines.begin(), lines.end(), std::string(),
|
||||||
[](std::string s, const std::string &s2) {
|
[](auto &&lines, auto &&line) -> auto { return lines + line; });
|
||||||
return std::move(s) + s2;
|
auto json_data = json::parse(txt.empty() ? "{}" : txt);
|
||||||
});
|
json_data[mount_id] = {
|
||||||
auto json = json::parse(txt.empty() ? "{}" : txt);
|
{"Active", active},
|
||||||
json[mount_id] = {{"Active", active},
|
{"Location", active ? mount_location : ""},
|
||||||
{"Location", active ? mount_location : ""},
|
{"PID", active ? pid : -1},
|
||||||
{"PID", active ? pid : -1}};
|
};
|
||||||
ret = utils::file::write_json_file(get_lock_data_file(), json);
|
ret = utils::file::write_json_file(get_lock_data_file(), json_data);
|
||||||
} else {
|
} else {
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ auto sia_provider::get_file(const std::string &api_path, api_file &file) const
|
|||||||
auto size{
|
auto size{
|
||||||
std::accumulate(
|
std::accumulate(
|
||||||
slabs.begin(), slabs.end(), std::uint64_t(0U),
|
slabs.begin(), slabs.end(), std::uint64_t(0U),
|
||||||
[](std::uint64_t total_size, const json &slab) -> std::uint64_t {
|
[](auto &&total_size, const json &slab) -> std::uint64_t {
|
||||||
return total_size + slab["Length"].get<std::uint64_t>();
|
return total_size + slab["Length"].get<std::uint64_t>();
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
@ -35,7 +35,7 @@ void polling::frequency_thread(
|
|||||||
unique_mutex_lock lock(mutex_);
|
unique_mutex_lock lock(mutex_);
|
||||||
auto futures = std::accumulate(
|
auto futures = std::accumulate(
|
||||||
items_.begin(), items_.end(), std::deque<tasks::task_ptr>{},
|
items_.begin(), items_.end(), std::deque<tasks::task_ptr>{},
|
||||||
[this, &freq](auto &&list, auto &&item) {
|
[this, &freq](auto &&list, auto &&item) -> auto {
|
||||||
if (item.second.freq != freq) {
|
if (item.second.freq != freq) {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user