diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp index bb23664d..a84fe21b 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp @@ -85,8 +85,8 @@ auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid, struct fuse_file_info * /*file_info*/) -> api_error { #else -auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid) - -> api_error { +auto fuse_drive::chown_impl(std::string api_path, uid_t uid, + gid_t gid) -> api_error { #endif return check_and_perform( api_path, X_OK, [&](api_meta_map &meta) -> api_error { @@ -494,8 +494,8 @@ auto fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st, struct fuse_file_info * /*file_info*/) -> api_error { #else -auto fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st) - -> api_error { +auto fuse_drive::getattr_impl(std::string api_path, + struct stat *unix_st) -> api_error { #endif auto parent = utils::path::get_parent_api_path(api_path); @@ -561,8 +561,8 @@ auto fuse_drive::getxtimes_impl(std::string api_path, struct timespec *bkuptime, #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 -auto fuse_drive::init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) - -> void * { +auto fuse_drive::init_impl(struct fuse_conn_info *conn, + struct fuse_config *cfg) -> void * { #else void *fuse_drive::init_impl(struct fuse_conn_info *conn) { #endif @@ -666,13 +666,17 @@ auto fuse_drive::mkdir_impl(std::string api_path, mode_t mode) -> api_error { } void fuse_drive::notify_fuse_main_exit(int &ret) { - if (was_mounted_) { - event_system::instance().raise( - function_name, get_mount_location(), std::to_string(ret)); - event_system::instance().stop(); - logging_consumer_.reset(); - console_consumer_.reset(); + REPERTORY_USES_FUNCTION_NAME(); + + if (not was_mounted_) { + return; } + + event_system::instance().raise( + function_name, get_mount_location(), std::to_string(ret)); + event_system::instance().stop(); + logging_consumer_.reset(); + console_consumer_.reset(); } auto fuse_drive::open_impl(std::string api_path, @@ -800,9 +804,8 @@ auto fuse_drive::release_impl(std::string /*api_path*/, return api_error::success; } -auto fuse_drive::releasedir_impl(std::string /*api_path*/, - struct fuse_file_info *file_info) - -> api_error { +auto fuse_drive::releasedir_impl( + std::string /*api_path*/, struct fuse_file_info *file_info) -> api_error { auto iter = directory_cache_->get_directory(file_info->fh); if (iter == nullptr) { return api_error::invalid_handle; @@ -820,8 +823,8 @@ auto fuse_drive::rename_directory(const std::string &from_api_path, } auto fuse_drive::rename_file(const std::string &from_api_path, - const std::string &to_api_path, bool overwrite) - -> int { + const std::string &to_api_path, + bool overwrite) -> int { auto res = fm_->rename_file(from_api_path, to_api_path, overwrite); errno = std::abs(utils::from_api_error(res)); return (res == api_error::success) ? 0 : -1; @@ -831,8 +834,8 @@ auto fuse_drive::rename_file(const std::string &from_api_path, auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path, unsigned int /*flags*/) -> api_error { #else -auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path) - -> api_error { +auto fuse_drive::rename_impl(std::string from_api_path, + std::string to_api_path) -> api_error { #endif auto res = check_parent_access(to_api_path, W_OK | X_OK); if (res != api_error::success) { @@ -934,15 +937,15 @@ auto fuse_drive::getxattr_impl(std::string api_path, const char *name, } #else // __APPLE__ auto fuse_drive::getxattr_impl(std::string api_path, const char *name, - char *value, size_t size, int &attribute_size) - -> api_error { + char *value, size_t size, + int &attribute_size) -> api_error { return getxattr_common(api_path, name, value, size, attribute_size, nullptr); } #endif // __APPLE__ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size, - int &required_size, bool &return_size) - -> api_error { + int &required_size, + bool &return_size) -> api_error { auto check_size = (size == 0); auto res = check_parent_access(api_path, X_OK); @@ -982,8 +985,8 @@ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size, return res; } -auto fuse_drive::removexattr_impl(std::string api_path, const char *name) - -> api_error { +auto fuse_drive::removexattr_impl(std::string api_path, + const char *name) -> api_error { std::string attribute_name; #if defined(__APPLE__) auto res = parse_xattr_parameters(name, 0, attribute_name, api_path); @@ -1011,8 +1014,8 @@ auto fuse_drive::setxattr_impl(std::string api_path, const char *name, uint32_t position) -> api_error { #else // __APPLE__ auto fuse_drive::setxattr_impl(std::string api_path, const char *name, - const char *value, size_t size, int flags) - -> api_error { + const char *value, size_t size, + int flags) -> api_error { #endif std::string attribute_name; #if defined(__APPLE__) @@ -1090,8 +1093,8 @@ void fuse_drive::set_item_meta(const std::string &api_path, } #if defined(__APPLE__) -auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr) - -> api_error { +auto fuse_drive::setattr_x_impl(std::string api_path, + struct setattr_x *attr) -> api_error { bool exists{}; auto res = provider_.is_file(api_path, exists); if (res != api_error::success) { @@ -1145,7 +1148,7 @@ auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr) ts[0].tv_sec = attr->acctime.tv_sec; ts[0].tv_nsec = attr->acctime.tv_nsec; } else { - struct timeval tv{}; + struct timeval tv {}; gettimeofday(&tv, NULL); ts[0].tv_sec = tv.tv_sec; ts[0].tv_nsec = tv.tv_usec * 1000; @@ -1190,9 +1193,8 @@ auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr) return api_error::success; } -auto fuse_drive::setbkuptime_impl(std::string api_path, - const struct timespec *bkuptime) - -> api_error { +auto fuse_drive::setbkuptime_impl( + std::string api_path, const struct timespec *bkuptime) -> api_error { return check_and_perform( api_path, X_OK, [&](api_meta_map &meta) -> api_error { auto nanos = bkuptime->tv_nsec + @@ -1228,8 +1230,8 @@ auto fuse_drive::setvolname_impl(const char * /*volname*/) -> api_error { return api_error::success; } -auto fuse_drive::statfs_x_impl(std::string /*api_path*/, struct statfs *stbuf) - -> api_error { +auto fuse_drive::statfs_x_impl(std::string /*api_path*/, + struct statfs *stbuf) -> api_error { if (statfs(&config_.get_cache_directory()[0], stbuf) != 0) { return api_error::os_error; } @@ -1254,8 +1256,8 @@ auto fuse_drive::statfs_x_impl(std::string /*api_path*/, struct statfs *stbuf) return api_error::success; } #else // __APPLE__ -auto fuse_drive::statfs_impl(std::string /*api_path*/, struct statvfs *stbuf) - -> api_error { +auto fuse_drive::statfs_impl(std::string /*api_path*/, + struct statvfs *stbuf) -> api_error { if (statvfs(config_.get_cache_directory().data(), stbuf) != 0) { return api_error::os_error; } @@ -1339,8 +1341,8 @@ auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2], struct fuse_file_info * /*file_info*/) -> api_error { #else -auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2]) - -> api_error { +auto fuse_drive::utimens_impl(std::string api_path, + const struct timespec tv[2]) -> api_error { #endif api_meta_map meta; auto res = provider_.get_item_meta(api_path, meta); diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp index f082eef3..3a05d683 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp @@ -26,6 +26,8 @@ #include "platform/platform.hpp" #include "providers/i_provider.hpp" #include "utils/common.hpp" +#include "utils/path.hpp" +#include "utils/string.hpp" #include "utils/time.hpp" namespace repertory { @@ -33,8 +35,8 @@ auto fuse_drive_base::access_impl(std::string api_path, int mask) -> api_error { return check_access(api_path, mask); } -auto fuse_drive_base::check_access(const std::string &api_path, int mask) const - -> api_error { +auto fuse_drive_base::check_access(const std::string &api_path, + int mask) const -> api_error { REPERTORY_USES_FUNCTION_NAME(); api_meta_map meta; @@ -135,9 +137,8 @@ auto fuse_drive_base::check_and_perform( return action(meta); } -auto fuse_drive_base::check_open_flags(int flags, int mask, - const api_error &fail_error) - -> api_error { +auto fuse_drive_base::check_open_flags( + int flags, int mask, const api_error &fail_error) -> api_error { return (((flags & mask) == 0) ? api_error::success : fail_error); } @@ -194,8 +195,8 @@ auto fuse_drive_base::check_parent_access(const std::string &api_path, return ret; } -auto fuse_drive_base::check_readable(int flags, const api_error &fail_error) - -> api_error { +auto fuse_drive_base::check_readable(int flags, + const api_error &fail_error) -> api_error { auto mode = (flags & O_ACCMODE); return ((mode == O_WRONLY) ? fail_error : api_error::success); } @@ -253,16 +254,13 @@ auto fuse_drive_base::get_uid_from_meta(const api_meta_map &meta) -> uid_t { } #if defined(__APPLE__) -auto fuse_drive_base::parse_xattr_parameters(const char *name, - const uint32_t &position, - std::string &attribute_name, - const std::string &api_path) - -> api_error { +auto fuse_drive_base::parse_xattr_parameters( + const char *name, const uint32_t &position, std::string &attribute_name, + const std::string &api_path) -> api_error { #else // !defined(__APPLE__) -auto fuse_drive_base::parse_xattr_parameters(const char *name, - std::string &attribute_name, - const std::string &api_path) - -> api_error { +auto fuse_drive_base::parse_xattr_parameters( + const char *name, std::string &attribute_name, + const std::string &api_path) -> api_error { #endif // defined(__APPLE__) auto res = api_path.empty() ? api_error::bad_address : api_error::success; if (res != api_error::success) { @@ -295,11 +293,9 @@ auto fuse_drive_base::parse_xattr_parameters( std::string &attribute_name, const std::string &api_path) -> api_error { auto res = parse_xattr_parameters(name, position, attribute_name, api_path); #else // !defined(__APPLE__) -auto fuse_drive_base::parse_xattr_parameters(const char *name, - const char *value, size_t size, - std::string &attribute_name, - const std::string &api_path) - -> api_error { +auto fuse_drive_base::parse_xattr_parameters( + const char *name, const char *value, size_t size, + std::string &attribute_name, const std::string &api_path) -> api_error { auto res = parse_xattr_parameters(name, attribute_name, api_path); #endif // defined(__APPLE__) if (res != api_error::success) { diff --git a/repertory/librepertory/src/file_manager/open_file.cpp b/repertory/librepertory/src/file_manager/open_file.cpp index bbb3dcac..a91e23d0 100644 --- a/repertory/librepertory/src/file_manager/open_file.cpp +++ b/repertory/librepertory/src/file_manager/open_file.cpp @@ -21,6 +21,7 @@ */ #include "file_manager/open_file.hpp" +#include "app_config.hpp" #include "events/event_system.hpp" #include "events/types/download_begin.hpp" #include "events/types/download_end.hpp" diff --git a/repertory/librepertory/src/file_manager/ring_buffer_base.cpp b/repertory/librepertory/src/file_manager/ring_buffer_base.cpp index 2a909b4d..e818ae76 100644 --- a/repertory/librepertory/src/file_manager/ring_buffer_base.cpp +++ b/repertory/librepertory/src/file_manager/ring_buffer_base.cpp @@ -21,6 +21,7 @@ */ #include "file_manager/ring_buffer_base.hpp" +#include "app_config.hpp" #include "events/event_system.hpp" #include "events/types/download_begin.hpp" #include "events/types/download_end.hpp"