refactor event system
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit

This commit is contained in:
2025-01-23 19:06:57 -06:00
parent 8272ec2f8a
commit 4b3582cbb0
16 changed files with 663 additions and 321 deletions

View File

@ -22,7 +22,6 @@
#ifndef REPERTORY_INCLUDE_APP_CONFIG_HPP_
#define REPERTORY_INCLUDE_APP_CONFIG_HPP_
#include "events/event.hpp"
#include "types/remote.hpp"
#include "types/repertory.hpp"
@ -32,26 +31,26 @@ private:
static stop_type stop_requested;
public:
[[nodiscard]] static auto default_agent_name(const provider_type &prov)
-> std::string;
[[nodiscard]] static auto
default_agent_name(const provider_type &prov) -> std::string;
[[nodiscard]] static auto default_api_port(const provider_type &prov)
-> std::uint16_t;
[[nodiscard]] static auto
default_api_port(const provider_type &prov) -> std::uint16_t;
[[nodiscard]] static auto default_data_directory(const provider_type &prov)
-> std::string;
[[nodiscard]] static auto
default_data_directory(const provider_type &prov) -> std::string;
[[nodiscard]] static auto default_remote_api_port(const provider_type &prov)
-> std::uint16_t;
[[nodiscard]] static auto
default_remote_api_port(const provider_type &prov) -> std::uint16_t;
[[nodiscard]] static auto default_rpc_port(const provider_type &prov)
-> std::uint16_t;
[[nodiscard]] static auto
default_rpc_port(const provider_type &prov) -> std::uint16_t;
[[nodiscard]] static auto get_provider_display_name(const provider_type &prov)
-> std::string;
[[nodiscard]] static auto
get_provider_display_name(const provider_type &prov) -> std::string;
[[nodiscard]] static auto get_provider_name(const provider_type &prov)
-> std::string;
[[nodiscard]] static auto
get_provider_name(const provider_type &prov) -> std::string;
public:
[[nodiscard]] static auto get_stop_requested() -> bool;
@ -193,8 +192,8 @@ public:
[[nodiscard]] auto get_task_wait_ms() const -> std::uint16_t;
[[nodiscard]] auto get_value_by_name(const std::string &name) const
-> std::string;
[[nodiscard]] auto
get_value_by_name(const std::string &name) const -> std::string;
[[nodiscard]] auto get_version() const -> std::uint64_t;

View File

@ -24,7 +24,7 @@
#if !defined(_WIN32)
#include "events/event_system2.hpp"
#include "utils/path.hpp"
#include "types/repertory.hpp"
namespace repertory {
class app_config;
@ -51,8 +51,8 @@ private:
std::string mount_location_;
protected:
bool atime_enabled_ = true;
bool console_enabled_ = false;
bool atime_enabled_{true};
bool console_enabled_{false};
std::optional<gid_t> forced_gid_;
std::optional<uid_t> forced_uid_;
std::optional<mode_t> forced_umask_;
@ -61,7 +61,7 @@ private:
static auto instance() -> fuse_base &;
private:
struct fuse_operations fuse_ops_{};
struct fuse_operations fuse_ops_ {};
private:
[[nodiscard]] auto
@ -78,9 +78,9 @@ private:
static void execute_void_callback(std::string_view function_name,
const std::function<void()> &cb);
static auto execute_void_pointer_callback(std::string_view function_name,
const std::function<void *()> &cb)
-> void *;
static auto
execute_void_pointer_callback(std::string_view function_name,
const std::function<void *()> &cb) -> void *;
void raise_fuse_event(std::string_view function_name,
std::string_view api_path, int ret,
@ -104,8 +104,8 @@ private:
[[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid,
struct fuse_file_info *fi) -> int;
#else
[[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid)
-> int;
[[nodiscard]] static auto chown_(const char *path, uid_t uid,
gid_t gid) -> int;
#endif
[[nodiscard]] static auto create_(const char *path, mode_t mode,
@ -114,8 +114,8 @@ private:
static void destroy_(void *ptr);
[[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset,
off_t length, struct fuse_file_info *fi)
-> int;
off_t length,
struct fuse_file_info *fi) -> int;
#if FUSE_USE_VERSION < 30
[[nodiscard]] static auto fgetattr_(const char *path, struct stat *st,
@ -156,8 +156,8 @@ private:
[[nodiscard]] static auto mkdir_(const char *path, mode_t mode) -> int;
[[nodiscard]] static auto open_(const char *path, struct fuse_file_info *fi)
-> int;
[[nodiscard]] static auto open_(const char *path,
struct fuse_file_info *fi) -> int;
[[nodiscard]] static auto opendir_(const char *path,
struct fuse_file_info *fi) -> int;
@ -174,8 +174,8 @@ private:
#else
[[nodiscard]] static auto readdir_(const char *path, void *buf,
fuse_fill_dir_t fuse_fill_dir,
off_t offset, struct fuse_file_info *fi)
-> int;
off_t offset,
struct fuse_file_info *fi) -> int;
#endif
[[nodiscard]] static auto release_(const char *path,
@ -207,8 +207,8 @@ private:
[[nodiscard]] static auto listxattr_(const char *path, char *buffer,
size_t size) -> int;
[[nodiscard]] static auto removexattr_(const char *path, const char *name)
-> int;
[[nodiscard]] static auto removexattr_(const char *path,
const char *name) -> int;
#if defined(__APPLE__)
[[nodiscard]] static auto setxattr_(const char *path, const char *name,
@ -217,18 +217,17 @@ private:
#else // __APPLE__
[[nodiscard]] static auto setxattr_(const char *path, const char *name,
const char *value, size_t size, int flags)
-> int;
const char *value, size_t size,
int flags) -> int;
#endif // __APPLE__
#endif // HAS_SETXATTR
#if defined(__APPLE__)
[[nodiscard]] static auto setattr_x_(const char *path, struct setattr_x *attr)
-> int;
[[nodiscard]] static auto setattr_x_(const char *path,
struct setattr_x *attr) -> int;
[[nodiscard]] static auto setbkuptime_(const char *path,
const struct timespec *bkuptime)
-> int;
[[nodiscard]] static auto
setbkuptime_(const char *path, const struct timespec *bkuptime) -> int;
[[nodiscard]] static auto setchgtime_(const char *path,
const struct timespec *chgtime) -> int;
@ -238,12 +237,12 @@ private:
[[nodiscard]] static auto setvolname_(const char *volname) -> int;
[[nodiscard]] static auto statfs_x_(const char *path, struct statfs *stbuf)
-> int;
[[nodiscard]] static auto statfs_x_(const char *path,
struct statfs *stbuf) -> int;
#else // __APPLE__
[[nodiscard]] static auto statfs_(const char *path, struct statvfs *stbuf)
-> int;
[[nodiscard]] static auto statfs_(const char *path,
struct statvfs *stbuf) -> int;
#endif // __APPLE__
#if FUSE_USE_VERSION >= 30
@ -269,8 +268,8 @@ private:
struct fuse_file_info *fi) -> int;
protected:
[[nodiscard]] virtual auto access_impl(std::string /*api_path*/, int /*mask*/)
-> api_error {
[[nodiscard]] virtual auto access_impl(std::string /*api_path*/,
int /*mask*/) -> api_error {
return api_error::not_implemented;
}
@ -282,10 +281,9 @@ protected:
#endif // __APPLE__
#if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/,
mode_t /*mode*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
chmod_impl(std::string /*api_path*/, mode_t /*mode*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
#else
@ -296,10 +294,9 @@ protected:
#endif
#if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/,
gid_t /*gid*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
chown_impl(std::string /*api_path*/, uid_t /*uid*/, gid_t /*gid*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
#else
@ -309,10 +306,9 @@ protected:
}
#endif
[[nodiscard]] virtual auto create_impl(std::string /*api_path*/,
mode_t /*mode*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
create_impl(std::string /*api_path*/, mode_t /*mode*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
@ -320,48 +316,43 @@ protected:
[[nodiscard]] virtual auto
fallocate_impl(std::string /*api_path*/, int /*mode*/, off_t /*offset*/,
off_t /*length*/, struct fuse_file_info * /*fi*/)
-> api_error {
off_t /*length*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
[[nodiscard]] virtual auto fgetattr_impl(std::string /*api_path*/,
struct stat * /*st*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
fgetattr_impl(std::string /*api_path*/, struct stat * /*st*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
#if defined(__APPLE__)
[[nodiscard]] virtual auto fsetattr_x_impl(std::string /*api_path*/,
struct setattr_x * /*attr*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
fsetattr_x_impl(std::string /*api_path*/, struct setattr_x * /*attr*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
#endif // __APPLE__
[[nodiscard]] virtual auto fsync_impl(std::string /*api_path*/,
int /*datasync*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
fsync_impl(std::string /*api_path*/, int /*datasync*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
#if FUSE_USE_VERSION < 30
[[nodiscard]] virtual auto ftruncate_impl(std::string /*api_path*/,
off_t /*size*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
ftruncate_impl(std::string /*api_path*/, off_t /*size*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
#endif
#if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/,
struct stat * /*st*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
getattr_impl(std::string /*api_path*/, struct stat * /*st*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
#else
@ -372,17 +363,16 @@ protected:
#endif
#if defined(__APPLE__)
[[nodiscard]] virtual auto getxtimes_impl(std::string /*api_path*/,
struct timespec * /*bkuptime*/,
struct timespec * /*crtime*/)
-> api_error {
[[nodiscard]] virtual auto
getxtimes_impl(std::string /*api_path*/, struct timespec * /*bkuptime*/,
struct timespec * /*crtime*/) -> api_error {
return api_error::not_implemented;
}
#endif // __APPLE__
#if FUSE_USE_VERSION >= 30
virtual auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg)
-> void *;
virtual auto init_impl(struct fuse_conn_info *conn,
struct fuse_config *cfg) -> void *;
#else
virtual auto init_impl(struct fuse_conn_info *conn) -> void *;
#endif
@ -392,15 +382,15 @@ protected:
return api_error::not_implemented;
}
[[nodiscard]] virtual auto open_impl(std::string /*api_path*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
open_impl(std::string /*api_path*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
[[nodiscard]] virtual auto opendir_impl(std::string /*api_path*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
opendir_impl(std::string /*api_path*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
@ -415,8 +405,8 @@ protected:
[[nodiscard]] virtual auto
readdir_impl(std::string /*api_path*/, void * /*buf*/,
fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/,
struct fuse_file_info * /*fi*/, fuse_readdir_flags /*flags*/)
-> api_error {
struct fuse_file_info * /*fi*/,
fuse_readdir_flags /*flags*/) -> api_error {
return api_error::not_implemented;
}
#else
@ -428,15 +418,15 @@ protected:
}
#endif
[[nodiscard]] virtual auto release_impl(std::string /*api_path*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
release_impl(std::string /*api_path*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
[[nodiscard]] virtual auto releasedir_impl(std::string /*api_path*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
releasedir_impl(std::string /*api_path*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
@ -447,9 +437,9 @@ protected:
return api_error::not_implemented;
}
#else
[[nodiscard]] virtual auto rename_impl(std::string /*from_api_path*/,
std::string /*to_api_path*/)
-> api_error {
[[nodiscard]] virtual auto
rename_impl(std::string /*from_api_path*/,
std::string /*to_api_path*/) -> api_error {
return api_error::not_implemented;
}
#endif
@ -469,8 +459,8 @@ protected:
#else // __APPLE__
[[nodiscard]] virtual auto
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 api_error::not_implemented;
}
#endif // __APPLE__
@ -481,9 +471,9 @@ protected:
return api_error::not_implemented;
}
[[nodiscard]] virtual auto removexattr_impl(std::string /*api_path*/,
const char * /*name*/)
-> api_error {
[[nodiscard]] virtual auto
removexattr_impl(std::string /*api_path*/,
const char * /*name*/) -> api_error {
return api_error::not_implemented;
}
@ -496,19 +486,20 @@ protected:
return api_error::not_implemented;
}
#else // __APPLE__
[[nodiscard]] virtual auto
setxattr_impl(std::string /*api_path*/, const char * /*name*/,
const char * /*value*/, size_t /*size*/, int /*flags*/)
-> api_error {
[[nodiscard]] virtual auto setxattr_impl(std::string /*api_path*/,
const char * /*name*/,
const char * /*value*/,
size_t /*size*/,
int /*flags*/) -> api_error {
return api_error::not_implemented;
}
#endif // __APPLE__
#endif // HAS_SETXATTR
#if defined(__APPLE__)
[[nodiscard]] virtual auto setattr_x_impl(std::string /*api_path*/,
struct setattr_x * /*attr*/)
-> api_error {
[[nodiscard]] virtual auto
setattr_x_impl(std::string /*api_path*/,
struct setattr_x * /*attr*/) -> api_error {
return api_error::not_implemented;
}
@ -519,40 +510,39 @@ protected:
}
[[nodiscard]] virtual auto
setchgtime_impl(std::string /*api_path*/, const struct timespec * /*chgtime*/)
-> api_error {
setchgtime_impl(std::string /*api_path*/,
const struct timespec * /*chgtime*/) -> api_error {
return api_error::not_implemented;
}
[[nodiscard]] virtual auto setcrtime_impl(std::string /*api_path*/,
const struct timespec * /*crtime*/)
-> api_error {
[[nodiscard]] virtual auto
setcrtime_impl(std::string /*api_path*/,
const struct timespec * /*crtime*/) -> api_error {
return api_error::not_implemented;
}
[[nodiscard]] virtual auto setvolname_impl(const char * /*volname*/)
-> api_error {
[[nodiscard]] virtual auto
setvolname_impl(const char * /*volname*/) -> api_error {
return api_error::not_implemented;
}
[[nodiscard]] virtual auto statfs_x_impl(std::string /*api_path*/,
struct statfs * /*stbuf*/)
-> api_error {
[[nodiscard]] virtual auto
statfs_x_impl(std::string /*api_path*/,
struct statfs * /*stbuf*/) -> api_error {
return api_error::not_implemented;
}
#else // __APPLE__
[[nodiscard]] virtual auto statfs_impl(std::string /*api_path*/,
struct statvfs * /*stbuf*/)
-> api_error {
[[nodiscard]] virtual auto
statfs_impl(std::string /*api_path*/,
struct statvfs * /*stbuf*/) -> api_error {
return api_error::not_implemented;
}
#endif // __APPLE__
#if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/,
off_t /*size*/,
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
truncate_impl(std::string /*api_path*/, off_t /*size*/,
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
#else
@ -562,22 +552,21 @@ protected:
}
#endif
[[nodiscard]] virtual auto unlink_impl(std::string /*api_path*/)
-> api_error {
[[nodiscard]] virtual auto
unlink_impl(std::string /*api_path*/) -> api_error {
return api_error::not_implemented;
}
#if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/,
const struct timespec /*tv*/[2],
struct fuse_file_info * /*fi*/)
-> api_error {
[[nodiscard]] virtual auto
utimens_impl(std::string /*api_path*/, const struct timespec /*tv*/[2],
struct fuse_file_info * /*fi*/) -> api_error {
return api_error::not_implemented;
}
#else
[[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/,
const struct timespec /*tv*/[2])
-> api_error {
[[nodiscard]] virtual auto
utimens_impl(std::string /*api_path*/,
const struct timespec /*tv*/[2]) -> api_error {
return api_error::not_implemented;
}
#endif
@ -585,8 +574,8 @@ protected:
[[nodiscard]] virtual auto
write_impl(std::string /*api_path*/, const char * /*buffer*/,
size_t /*write_size*/, off_t /*write_offset*/,
struct fuse_file_info * /*fi*/, std::size_t & /*bytes_written*/)
-> api_error {
struct fuse_file_info * /*fi*/,
std::size_t & /*bytes_written*/) -> api_error {
return api_error::not_implemented;
}

View File

@ -22,37 +22,10 @@
#ifndef REPERTORY_INCLUDE_EVENTS_EVENTS_HPP_
#define REPERTORY_INCLUDE_EVENTS_EVENTS_HPP_
#include "events/event_system.hpp"
#include "types/repertory.hpp"
#include "utils/utils.hpp"
namespace repertory {
// clang-format off
E_SIMPLE(unmount_requested, info);
#if !defined(_WIN32)
E_SIMPLE2(unmount_result, info,
std::string, location, loc, E_FROM_STRING,
std::string, result, res, E_FROM_STRING
);
#endif
E_SIMPLE2(download_begin, info,
std::string, api_path, ap, E_FROM_STRING,
std::string, dest_path, dest, E_FROM_STRING
);
E_SIMPLE3(download_end, info,
std::string, api_path, ap, E_FROM_STRING,
std::string, dest_path, dest, E_FROM_STRING,
api_error, result, result, E_FROM_API_FILE_ERROR
);
E_SIMPLE3(download_progress, info,
std::string, api_path, ap, E_FROM_STRING,
std::string, dest_path, dest, E_FROM_STRING,
double, progress, prog, E_FROM_DOUBLE_PRECISE
);
E_SIMPLE2(download_restored, info,
std::string, api_path, ap, E_FROM_STRING,
std::string, dest_path, dest, E_FROM_STRING

View File

@ -0,0 +1,74 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_BEGIN_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_BEGIN_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
namespace repertory {
struct download_begin final : public i_event {
download_begin() = default;
download_begin(std::string api_path_, std::string dest_path_,
std::string_view function_name_)
: api_path(std::move(api_path_)),
dest_path(std::move(dest_path_)),
function_name(std::string(function_name_)) {}
static constexpr const std::string_view name{"download_begin"};
std::string api_path;
std::string dest_path;
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return event_level::info;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|dp|{}", name, function_name, api_path,
dest_path);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::download_begin> {
static void to_json(json &data, const repertory::download_begin &value) {
data["api_path"] = value.api_path;
data["dest_path"] = value.dest_path;
data["function_name"] = value.function_name;
}
static void from_json(const json &data, repertory::download_begin &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("dest_path").get_to<std::string>(value.dest_path);
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_BEGIN_HPP_

View File

@ -0,0 +1,79 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_END_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_END_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
namespace repertory {
struct download_end final : public i_event {
download_end() = default;
download_end(std::string api_path_, std::string dest_path_, api_error error_,
std::string_view function_name_)
: api_path(std::move(api_path_)),
dest_path(std::move(dest_path_)),
error(error_),
function_name(std::string(function_name_)) {}
static constexpr const std::string_view name{"download_end"};
std::string api_path;
std::string dest_path;
api_error error{};
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return event_level::info;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|dp|{}|error|{}", name, function_name,
api_path, dest_path, api_error_to_string(error));
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::download_end> {
static void to_json(json &data, const repertory::download_end &value) {
data["api_path"] = value.api_path;
data["dest_path"] = value.dest_path;
data["error"] = repertory::api_error_to_string(value.error);
data["function_name"] = value.function_name;
}
static void from_json(const json &data, repertory::download_end &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("dest_path").get_to<std::string>(value.dest_path);
value.error =
repertory::api_error_from_string(data.at("error").get<std::string>());
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_END_HPP_

View File

@ -0,0 +1,78 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_PROGRESS_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_PROGRESS_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
namespace repertory {
struct download_progress final : public i_event {
download_progress() = default;
download_progress(std::string api_path_, std::string dest_path_,
std::string_view function_name_, double progress_)
: api_path(std::move(api_path_)),
dest_path(std::move(dest_path_)),
function_name(std::string(function_name_)),
progress(progress_) {}
static constexpr const std::string_view name{"download_progress"};
std::string api_path;
std::string dest_path;
std::string function_name;
double progress{};
[[nodiscard]] auto get_event_level() const -> event_level override {
return event_level::info;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|ap|{}|dp|{}|prog|{}", name, function_name,
api_path, dest_path, progress);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::download_progress> {
static void to_json(json &data, const repertory::download_progress &value) {
data["api_path"] = value.api_path;
data["dest_path"] = value.dest_path;
data["function_name"] = value.function_name;
data["progress"] = value.progress;
}
static void from_json(const json &data, repertory::download_progress &value) {
data.at("api_path").get_to<std::string>(value.api_path);
data.at("dest_path").get_to<std::string>(value.dest_path);
data.at("function_name").get_to<std::string>(value.function_name);
data.at("progress").get_to<double>(value.progress);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DOWNLOAD_PROGRESS_HPP_

View File

@ -0,0 +1,64 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_UNMOUNT_REQUESTED_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_UNMOUNT_REQUESTED_HPP_
#include "events/i_event.hpp"
#include "types/repertory.hpp"
namespace repertory {
struct unmount_requested final : public i_event {
unmount_requested() = default;
unmount_requested(std::string_view function_name_)
: function_name(std::string(function_name_)) {}
static constexpr const std::string_view name{"unmount_requested"};
std::string function_name;
[[nodiscard]] auto get_event_level() const -> event_level override {
return event_level::info;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}", name, function_name);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::unmount_requested> {
static void to_json(json &data, const repertory::unmount_requested &value) {
data["function_name"] = value.function_name;
}
static void from_json(const json &data, repertory::unmount_requested &value) {
data.at("function_name").get_to<std::string>(value.function_name);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_UNMOUNT_REQUESTED_HPP_

View File

@ -0,0 +1,76 @@
/*
Copyright <2018-2025> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_UNMOUNT_RESULT_HPP_
#define REPERTORY_INCLUDE_EVENTS_TYPES_UNMOUNT_RESULT_HPP_
#if !defined(_WIN32)
#include "events/i_event.hpp"
#include "types/repertory.hpp"
namespace repertory {
struct unmount_result final : public i_event {
unmount_result() = default;
unmount_result(std::string_view function_name_, std::string mount_location_,
std::int32_t result_)
: function_name(std::string(function_name_)),
mount_location(std::move(mount_location_)),
result(result_) {}
static constexpr const std::string_view name{"unmount_result"};
std::string function_name;
std::string mount_location;
std::int32_t result{};
[[nodiscard]] auto get_event_level() const -> event_level override {
return event_level::info;
}
[[nodiscard]] auto get_name() const -> std::string_view override {
return name;
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|location|{}|result|{}", name, function_name,
mount_location, result);
}
};
} // namespace repertory
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer<repertory::unmount_result> {
static void to_json(json &data, const repertory::unmount_result &value) {
data["function_name"] = value.function_name;
data["mount_location"] = value.mount_location;
data["result"] = value.result;
}
static void from_json(const json &data, repertory::unmount_result &value) {
data.at("function_name").get_to<std::string>(value.function_name);
data.at("mount_location").get_to<std::string>(value.mount_location);
data.at("result").get_to<std::int32_t>(value.result);
}
};
NLOHMANN_JSON_NAMESPACE_END
#endif // defined(_WIN32)
#endif // REPERTORY_INCLUDE_EVENTS_TYPES_UNMOUNT_RESULT_HPP_

View File

@ -25,6 +25,8 @@
#include "app_config.hpp"
#include "events/event_system2.hpp"
#include "events/types/unmount_requested.hpp"
#include "events/types/unmount_result.hpp"
#include "initialize.hpp"
#include "platform/platform.hpp"
#include "utils/collection.hpp"
@ -116,8 +118,8 @@ auto fuse_base::chflags_(const char *path, uint32_t flags) -> int {
#endif // __APPLE__
#if FUSE_USE_VERSION >= 30
auto fuse_base::chmod_(const char *path, mode_t mode, struct fuse_file_info *fi)
-> int {
auto fuse_base::chmod_(const char *path, mode_t mode,
struct fuse_file_info *fi) -> int {
REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback(
@ -184,7 +186,7 @@ void fuse_base::display_options(
#if FUSE_USE_VERSION >= 30
fuse_cmdline_help();
#else
struct fuse_operations fuse_ops{};
struct fuse_operations fuse_ops {};
fuse_main(args.size(),
reinterpret_cast<char **>(const_cast<char **>(args.data())),
&fuse_ops, nullptr);
@ -194,7 +196,7 @@ void fuse_base::display_options(
}
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()),
reinterpret_cast<char **>(const_cast<char **>(args.data())),
&fuse_ops, nullptr);
@ -332,8 +334,8 @@ auto fuse_base::getxtimes_(const char *path, struct timespec *bkuptime,
#endif // __APPLE__
#if FUSE_USE_VERSION >= 30
auto fuse_base::init_(struct fuse_conn_info *conn, struct fuse_config *cfg)
-> void * {
auto fuse_base::init_(struct fuse_conn_info *conn,
struct fuse_config *cfg) -> void * {
REPERTORY_USES_FUNCTION_NAME();
return execute_void_pointer_callback(function_name, [&]() -> void * {
@ -406,7 +408,7 @@ auto fuse_base::mount(std::vector<std::string> args) -> int {
char *mount_location{nullptr};
#if FUSE_USE_VERSION >= 30
struct fuse_cmdline_opts opts{};
struct fuse_cmdline_opts opts {};
fuse_parse_cmdline(&fa, &opts);
mount_location = opts.mountpoint;
#else
@ -475,8 +477,8 @@ auto fuse_base::read_(const char *path, char *buffer, size_t read_size,
#if FUSE_USE_VERSION >= 30
auto fuse_base::readdir_(const char *path, void *buf,
fuse_fill_dir_t fuse_fill_dir, off_t offset,
struct fuse_file_info *fi, fuse_readdir_flags flags)
-> int {
struct fuse_file_info *fi,
fuse_readdir_flags flags) -> int {
REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback(
@ -508,8 +510,8 @@ auto fuse_base::release_(const char *path, struct fuse_file_info *fi) -> int {
});
}
auto fuse_base::releasedir_(const char *path, struct fuse_file_info *fi)
-> int {
auto fuse_base::releasedir_(const char *path,
struct fuse_file_info *fi) -> int {
REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback(
@ -519,8 +521,8 @@ auto fuse_base::releasedir_(const char *path, struct fuse_file_info *fi)
}
#if FUSE_USE_VERSION >= 30
auto fuse_base::rename_(const char *from, const char *to, unsigned int flags)
-> int {
auto fuse_base::rename_(const char *from, const char *to,
unsigned int flags) -> int {
REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback(
@ -748,9 +750,11 @@ auto fuse_base::setxattr_(const char *path, const char *name, const char *value,
#endif // HAS_SETXATTR
void fuse_base::shutdown() {
const auto res = unmount(get_mount_location());
event_system2::instance().raise<unmount_result>(get_mount_location(),
std::to_string(res));
REPERTORY_USES_FUNCTION_NAME();
auto res = unmount(get_mount_location());
event_system2::instance().raise<unmount_result>(function_name,
get_mount_location(), res);
}
#if defined(__APPLE__)
@ -763,8 +767,8 @@ auto fuse_base::setattr_x_(const char *path, struct setattr_x *attr) -> int {
});
}
auto fuse_base::setbkuptime_(const char *path, const struct timespec *bkuptime)
-> int {
auto fuse_base::setbkuptime_(const char *path,
const struct timespec *bkuptime) -> int {
REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback(
@ -773,8 +777,8 @@ auto fuse_base::setbkuptime_(const char *path, const struct timespec *bkuptime)
});
}
auto fuse_base::setchgtime_(const char *path, const struct timespec *chgtime)
-> int {
auto fuse_base::setchgtime_(const char *path,
const struct timespec *chgtime) -> int {
REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback(
@ -783,8 +787,8 @@ auto fuse_base::setchgtime_(const char *path, const struct timespec *chgtime)
});
}
auto fuse_base::setcrtime_(const char *path, const struct timespec *crtime)
-> int {
auto fuse_base::setcrtime_(const char *path,
const struct timespec *crtime) -> int {
REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback(

View File

@ -31,6 +31,7 @@
#include "events/types/drive_mounted.hpp"
#include "events/types/drive_unmount_pending.hpp"
#include "events/types/drive_unmounted.hpp"
#include "events/types/unmount_requested.hpp"
#include "platform/platform.hpp"
#include "rpc/server/server.hpp"
#include "types/remote.hpp"
@ -42,8 +43,8 @@
#include "utils/utils.hpp"
namespace repertory::remote_fuse {
auto remote_fuse_drive::access_impl(std::string api_path, int mask)
-> api_error {
auto remote_fuse_drive::access_impl(std::string api_path,
int mask) -> api_error {
return utils::to_api_error(
remote_instance_->fuse_access(api_path.c_str(), mask));
}
@ -61,8 +62,8 @@ auto remote_fuse_drive::chmod_impl(std::string api_path, mode_t mode,
struct fuse_file_info * /*f_info*/)
-> api_error {
#else
auto remote_fuse_drive::chmod_impl(std::string api_path, mode_t mode)
-> api_error {
auto remote_fuse_drive::chmod_impl(std::string api_path,
mode_t mode) -> api_error {
#endif
return utils::to_api_error(remote_instance_->fuse_chmod(
api_path.c_str(), static_cast<remote::file_mode>(mode)));
@ -73,8 +74,8 @@ auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid,
struct fuse_file_info * /*f_info*/)
-> api_error {
#else
auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid)
-> api_error {
auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid,
gid_t gid) -> api_error {
#endif
return utils::to_api_error(
remote_instance_->fuse_chown(api_path.c_str(), uid, gid));
@ -120,10 +121,9 @@ void remote_fuse_drive::destroy_impl(void *ptr) {
fuse_base::destroy_impl(ptr);
}
auto remote_fuse_drive::fgetattr_impl(std::string api_path,
struct stat *unix_st,
struct fuse_file_info *f_info)
-> api_error {
auto remote_fuse_drive::fgetattr_impl(
std::string api_path, struct stat *unix_st,
struct fuse_file_info *f_info) -> api_error {
remote::stat r_stat{};
auto directory = false;
@ -184,8 +184,8 @@ auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st,
struct fuse_file_info * /*f_info*/)
-> api_error {
#else
auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st)
-> api_error {
auto remote_fuse_drive::getattr_impl(std::string api_path,
struct stat *unix_st) -> api_error {
#endif
bool directory = false;
remote::stat r_stat{};
@ -269,8 +269,8 @@ auto remote_fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * {
return ret;
}
auto remote_fuse_drive::mkdir_impl(std::string api_path, mode_t mode)
-> api_error {
auto remote_fuse_drive::mkdir_impl(std::string api_path,
mode_t mode) -> api_error {
return utils::to_api_error(remote_instance_->fuse_mkdir(
api_path.c_str(), static_cast<remote::file_mode>(mode)));
}
@ -295,9 +295,8 @@ auto remote_fuse_drive::open_impl(std::string api_path,
f_info->fh));
}
auto remote_fuse_drive::opendir_impl(std::string api_path,
struct fuse_file_info *f_info)
-> api_error {
auto remote_fuse_drive::opendir_impl(
std::string api_path, struct fuse_file_info *f_info) -> api_error {
if ((f_info->flags & O_APPEND) == O_APPEND ||
(f_info->flags & O_EXCL) == O_EXCL) {
return api_error::directory_exists;
@ -374,18 +373,14 @@ auto remote_fuse_drive::read_impl(std::string api_path, char *buffer,
}
#if FUSE_USE_VERSION >= 30
auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf,
fuse_fill_dir_t fuse_fill_dir,
off_t offset,
struct fuse_file_info *f_info,
fuse_readdir_flags /*flags*/)
-> api_error {
auto remote_fuse_drive::readdir_impl(
std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
off_t offset, struct fuse_file_info *f_info,
fuse_readdir_flags /*flags*/) -> api_error {
#else
auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf,
fuse_fill_dir_t fuse_fill_dir,
off_t offset,
struct fuse_file_info *f_info)
-> api_error {
auto remote_fuse_drive::readdir_impl(
std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
off_t offset, struct fuse_file_info *f_info) -> api_error {
#endif
std::string item_path;
int res = 0;
@ -413,16 +408,14 @@ auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf,
return utils::to_api_error(res);
}
auto remote_fuse_drive::release_impl(std::string api_path,
struct fuse_file_info *f_info)
-> api_error {
auto remote_fuse_drive::release_impl(
std::string api_path, struct fuse_file_info *f_info) -> api_error {
return utils::to_api_error(
remote_instance_->fuse_release(api_path.c_str(), f_info->fh));
}
auto remote_fuse_drive::releasedir_impl(std::string api_path,
struct fuse_file_info *f_info)
-> api_error {
auto remote_fuse_drive::releasedir_impl(
std::string api_path, struct fuse_file_info *f_info) -> api_error {
return utils::to_api_error(
remote_instance_->fuse_releasedir(api_path.c_str(), f_info->fh));
}
@ -519,8 +512,8 @@ api_error remote_fuse_drive::statfs_x_impl(std::string api_path,
return utils::to_api_error(res);
}
#else // __APPLE__
auto remote_fuse_drive::statfs_impl(std::string api_path, struct statvfs *stbuf)
-> api_error {
auto remote_fuse_drive::statfs_impl(std::string api_path,
struct statvfs *stbuf) -> api_error {
auto res = statvfs(config_.get_data_directory().c_str(), stbuf);
if (res == 0) {
remote::statfs r_stat{};
@ -547,8 +540,8 @@ auto remote_fuse_drive::truncate_impl(std::string api_path, off_t size,
struct fuse_file_info * /*f_info*/)
-> api_error {
#else
auto remote_fuse_drive::truncate_impl(std::string api_path, off_t size)
-> api_error {
auto remote_fuse_drive::truncate_impl(std::string api_path,
off_t size) -> api_error {
#endif
return utils::to_api_error(remote_instance_->fuse_truncate(
api_path.c_str(), static_cast<remote::file_offset>(size)));
@ -559,10 +552,9 @@ auto remote_fuse_drive::unlink_impl(std::string api_path) -> api_error {
}
#if FUSE_USE_VERSION >= 30
auto remote_fuse_drive::utimens_impl(std::string api_path,
const struct timespec tv[2],
struct fuse_file_info * /*f_info*/)
-> api_error {
auto remote_fuse_drive::utimens_impl(
std::string api_path, const struct timespec tv[2],
struct fuse_file_info * /*f_info*/) -> api_error {
#else
auto remote_fuse_drive::utimens_impl(std::string api_path,
const struct timespec tv[2]) -> api_error {

View File

@ -29,6 +29,7 @@
#include "events/event_system2.hpp"
#include "events/types/drive_mount_failed.hpp"
#include "events/types/drive_mount_result.hpp"
#include "events/types/unmount_requested.hpp"
#include "platform/platform.hpp"
#include "rpc/server/server.hpp"
#include "utils/collection.hpp"
@ -128,8 +129,8 @@ auto remote_winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, UINT32 attributes,
PSECURITY_DESCRIPTOR /*descriptor*/,
UINT64 allocation_size, PVOID * /*file_node*/,
PVOID *file_desc, OpenFileInfo *ofi)
-> NTSTATUS {
PVOID *file_desc,
OpenFileInfo *ofi) -> NTSTATUS {
remote::file_info fi{};
std::string normalized_name;
BOOLEAN exists = 0;
@ -163,10 +164,9 @@ auto remote_winfsp_drive::GetFileInfo(PVOID /*file_node*/, PVOID file_desc,
return ret;
}
auto remote_winfsp_drive::GetSecurityByName(PWSTR file_name, PUINT32 attributes,
PSECURITY_DESCRIPTOR descriptor,
SIZE_T *descriptor_size)
-> NTSTATUS {
auto remote_winfsp_drive::GetSecurityByName(
PWSTR file_name, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor,
SIZE_T *descriptor_size) -> NTSTATUS {
std::wstring string_descriptor;
std::uint64_t sds = (descriptor_size == nullptr) ? 0 : *descriptor_size;
auto ret = remote_instance_->winfsp_get_security_by_name(
@ -286,8 +286,8 @@ auto remote_winfsp_drive::Mounted(PVOID host) -> NTSTATUS {
auto remote_winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID * /*file_node*/,
PVOID *file_desc, OpenFileInfo *ofi)
-> NTSTATUS {
PVOID *file_desc,
OpenFileInfo *ofi) -> NTSTATUS {
remote::file_info fi{};
std::string normalize_name;
auto ret =
@ -307,8 +307,8 @@ auto remote_winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
auto remote_winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc,
UINT32 attributes,
BOOLEAN replace_attributes,
UINT64 allocation_size, FileInfo *file_info)
-> NTSTATUS {
UINT64 allocation_size,
FileInfo *file_info) -> NTSTATUS {
remote::file_info info{};
auto ret = remote_instance_->winfsp_overwrite(
file_desc, attributes, replace_attributes, allocation_size, &info);
@ -425,8 +425,8 @@ auto remote_winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc,
UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time,
UINT64 last_write_time,
UINT64 change_time, FileInfo *file_info)
-> NTSTATUS {
UINT64 change_time,
FileInfo *file_info) -> NTSTATUS {
remote::file_info fi{};
auto ret = remote_instance_->winfsp_set_basic_info(
file_desc, attributes, creation_time, last_access_time, last_write_time,
@ -478,8 +478,8 @@ VOID remote_winfsp_drive::Unmounted(PVOID host) {
auto remote_winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc,
PVOID buffer, UINT64 offset, ULONG length,
BOOLEAN write_to_end, BOOLEAN constrained_io,
PULONG bytes_transferred, FileInfo *file_info)
-> NTSTATUS {
PULONG bytes_transferred,
FileInfo *file_info) -> NTSTATUS {
remote::file_info fi{};
auto ret = remote_instance_->winfsp_write(
file_desc, buffer, offset, length, write_to_end, constrained_io,

View File

@ -33,6 +33,7 @@
#include "events/types/drive_mounted.hpp"
#include "events/types/drive_unmount_pending.hpp"
#include "events/types/drive_unmounted.hpp"
#include "events/types/unmount_requested.hpp"
#include "platform/platform.hpp"
#include "providers/i_provider.hpp"
#include "types/repertory.hpp"
@ -99,8 +100,8 @@ auto winfsp_drive::handle_error(std::string_view function_name,
return ret;
}
auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/, PWSTR * /*Argv*/)
-> NTSTATUS {
auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/,
PWSTR * /*Argv*/) -> NTSTATUS {
REPERTORY_USES_FUNCTION_NAME();
auto mount_location = utils::string::to_lower(
@ -483,10 +484,9 @@ auto winfsp_drive::get_item_meta(const std::string &api_path,
return ret;
}
auto winfsp_drive::get_security_by_name(PWSTR file_name, PUINT32 attributes,
PSECURITY_DESCRIPTOR descriptor,
std::uint64_t *descriptor_size)
-> NTSTATUS {
auto winfsp_drive::get_security_by_name(
PWSTR file_name, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor,
std::uint64_t *descriptor_size) -> NTSTATUS {
auto api_path =
utils::path::create_api_path(utils::string::to_utf8(file_name));
@ -746,8 +746,8 @@ auto winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
auto winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc,
UINT32 attributes, BOOLEAN replace_attributes,
UINT64 /*allocation_size*/, FileInfo *file_info)
-> NTSTATUS {
UINT64 /*allocation_size*/,
FileInfo *file_info) -> NTSTATUS {
REPERTORY_USES_FUNCTION_NAME();
std::string api_path;
@ -853,8 +853,8 @@ void winfsp_drive::populate_file_info(std::uint64_t file_size,
}
auto winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, PVOID buffer,
UINT64 offset, ULONG length, PULONG bytes_transferred)
-> NTSTATUS {
UINT64 offset, ULONG length,
PULONG bytes_transferred) -> NTSTATUS {
REPERTORY_USES_FUNCTION_NAME();
*bytes_transferred = 0U;
@ -909,8 +909,8 @@ auto winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, PVOID buffer,
auto winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
PWSTR /*pattern*/, PWSTR marker, PVOID buffer,
ULONG buffer_length, PULONG bytes_transferred)
-> NTSTATUS {
ULONG buffer_length,
PULONG bytes_transferred) -> NTSTATUS {
REPERTORY_USES_FUNCTION_NAME();
std::string api_path;
@ -1066,8 +1066,8 @@ auto winfsp_drive::Rename(PVOID /*file_node*/, PVOID /*file_desc*/,
auto winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc,
UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_write_time,
UINT64 change_time, FileInfo *file_info)
-> NTSTATUS {
UINT64 change_time,
FileInfo *file_info) -> NTSTATUS {
REPERTORY_USES_FUNCTION_NAME();
std::string api_path;

View File

@ -21,6 +21,10 @@
*/
#include "file_manager/open_file.hpp"
#include "events/event_system2.hpp"
#include "events/types/download_begin.hpp"
#include "events/types/download_end.hpp"
#include "events/types/download_progress.hpp"
#include "file_manager/cache_size_mgr.hpp"
#include "file_manager/file_manager.hpp"
#include "file_manager/i_upload_manager.hpp"
@ -117,8 +121,8 @@ open_file::open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
open_file::~open_file() { close(); }
auto open_file::adjust_cache_size(std::uint64_t file_size, bool shrink)
-> api_error {
auto open_file::adjust_cache_size(std::uint64_t file_size,
bool shrink) -> api_error {
REPERTORY_USES_FUNCTION_NAME();
if (file_size == get_file_size()) {
@ -269,6 +273,8 @@ auto open_file::close() -> bool {
void open_file::download_chunk(std::size_t chunk, bool skip_active,
bool should_reset) {
REPERTORY_USES_FUNCTION_NAME();
if (should_reset) {
reset_timeout();
}
@ -293,8 +299,8 @@ void open_file::download_chunk(std::size_t chunk, bool skip_active,
auto data_size = (chunk == read_state.size() - 1U) ? get_last_chunk_size()
: get_chunk_size();
if (get_active_downloads().empty() && (read_state.count() == 0U)) {
event_system2::instance().raise<download_begin>(get_api_path(),
get_source_path());
event_system2::instance().raise<download_begin>(
get_api_path(), get_source_path(), function_name);
}
get_active_downloads()[chunk] = std::make_shared<download>();
@ -317,16 +323,18 @@ void open_file::download_chunk(std::size_t chunk, bool skip_active,
static_cast<double>(state.size())) *
100.0;
event_system2::instance().raise<download_progress>(
get_api_path(), get_source_path(), progress);
get_api_path(), get_source_path(), function_name, progress);
if (state.all() && not notified_) {
notified_ = true;
event_system2::instance().raise<download_end>(
get_api_path(), get_source_path(), get_api_error());
get_api_path(), get_source_path(), get_api_error(),
function_name);
}
} else if (not notified_) {
notified_ = true;
event_system2::instance().raise<download_end>(
get_api_path(), get_source_path(), get_api_error());
get_api_path(), get_source_path(), get_api_error(),
function_name);
}
lock.unlock();

View File

@ -22,6 +22,9 @@
#include "file_manager/ring_buffer_base.hpp"
#include "events/event_system2.hpp"
#include "events/types/download_begin.hpp"
#include "events/types/download_end.hpp"
#include "events/types/download_progress.hpp"
#include "file_manager/open_file_base.hpp"
#include "platform/platform.hpp"
#include "providers/i_provider.hpp"
@ -64,8 +67,8 @@ auto ring_buffer_base::check_start() -> api_error {
return api_error::success;
}
event_system2::instance().raise<download_begin>(get_api_path(),
get_source_path());
event_system2::instance().raise<download_begin>(
get_api_path(), get_source_path(), function_name);
reader_thread_ =
std::make_unique<std::thread>([this]() { reader_thread(); });
return api_error::success;
@ -94,8 +97,10 @@ auto ring_buffer_base::close() -> bool {
return res;
}
auto ring_buffer_base::download_chunk(std::size_t chunk, bool skip_active)
-> api_error {
auto ring_buffer_base::download_chunk(std::size_t chunk,
bool skip_active) -> api_error {
REPERTORY_USES_FUNCTION_NAME();
unique_mutex_lock chunk_lock(chunk_mtx_);
const auto unlock_and_notify = [this, &chunk_lock]() {
chunk_notify_.notify_all();
@ -156,7 +161,7 @@ auto ring_buffer_base::download_chunk(std::size_t chunk, bool skip_active)
static_cast<double>(total_chunks_)) *
100.0;
event_system2::instance().raise<download_progress>(
get_api_path(), get_source_path(), progress);
get_api_path(), get_source_path(), function_name, progress);
}
}
@ -255,6 +260,8 @@ auto ring_buffer_base::read(std::size_t read_size, std::uint64_t read_offset,
}
void ring_buffer_base::reader_thread() {
REPERTORY_USES_FUNCTION_NAME();
unique_mutex_lock chunk_lock(chunk_mtx_);
auto next_chunk{ring_pos_};
chunk_notify_.notify_all();
@ -292,7 +299,8 @@ void ring_buffer_base::reader_thread() {
}
event_system2::instance().raise<download_end>(
get_api_path(), get_source_path(), api_error::download_stopped);
get_api_path(), get_source_path(), api_error::download_stopped,
function_name);
}
void ring_buffer_base::reverse(std::size_t count) {

View File

@ -37,6 +37,7 @@
#include "events/types/provider_offline.hpp"
#include "events/types/provider_upload_begin.hpp"
#include "events/types/provider_upload_end.hpp"
#include "events/types/unmount_requested.hpp"
#include "file_manager/cache_size_mgr.hpp"
#include "file_manager/i_file_manager.hpp"
#include "platform/platform.hpp"
@ -68,8 +69,8 @@ void base_provider::add_all_items(stop_type &stop_requested) {
}
auto base_provider::create_api_file(std::string path, std::string key,
std::uint64_t size, std::uint64_t file_time)
-> api_file {
std::uint64_t size,
std::uint64_t file_time) -> api_file {
api_file file{};
file.api_path = utils::path::create_api_path(path);
file.api_parent = utils::path::get_parent_api_path(file.api_path);
@ -101,8 +102,8 @@ auto base_provider::create_api_file(std::string path, std::uint64_t size,
}
auto base_provider::create_directory_clone_source_meta(
const std::string &source_api_path, const std::string &api_path)
-> api_error {
const std::string &source_api_path,
const std::string &api_path) -> api_error {
REPERTORY_USES_FUNCTION_NAME();
bool exists{};
@ -200,8 +201,8 @@ auto base_provider::create_directory(const std::string &api_path,
return api_error::error;
}
auto base_provider::create_file(const std::string &api_path, api_meta_map &meta)
-> api_error {
auto base_provider::create_file(const std::string &api_path,
api_meta_map &meta) -> api_error {
REPERTORY_USES_FUNCTION_NAME();
try {
@ -258,9 +259,8 @@ auto base_provider::create_file(const std::string &api_path, api_meta_map &meta)
return api_error::error;
}
auto base_provider::get_api_path_from_source(const std::string &source_path,
std::string &api_path) const
-> api_error {
auto base_provider::get_api_path_from_source(
const std::string &source_path, std::string &api_path) const -> api_error {
REPERTORY_USES_FUNCTION_NAME();
if (source_path.empty()) {
@ -273,9 +273,8 @@ auto base_provider::get_api_path_from_source(const std::string &source_path,
return db3_->get_api_path(source_path, api_path);
}
auto base_provider::get_directory_items(const std::string &api_path,
directory_item_list &list) const
-> api_error {
auto base_provider::get_directory_items(
const std::string &api_path, directory_item_list &list) const -> api_error {
REPERTORY_USES_FUNCTION_NAME();
try {
@ -339,10 +338,9 @@ auto base_provider::get_file_size(const std::string &api_path,
return api_error::success;
}
auto base_provider::get_filesystem_item(const std::string &api_path,
bool directory,
filesystem_item &fsi) const
-> api_error {
auto base_provider::get_filesystem_item(
const std::string &api_path, bool directory,
filesystem_item &fsi) const -> api_error {
bool exists{};
auto res = is_directory(api_path, exists);
if (res != api_error::success) {
@ -375,10 +373,9 @@ auto base_provider::get_filesystem_item(const std::string &api_path,
return api_error::success;
}
auto base_provider::get_filesystem_item_and_file(const std::string &api_path,
api_file &file,
filesystem_item &fsi) const
-> api_error {
auto base_provider::get_filesystem_item_and_file(
const std::string &api_path, api_file &file,
filesystem_item &fsi) const -> api_error {
auto res = get_file(api_path, file);
if (res != api_error::success) {
return res;
@ -713,6 +710,8 @@ auto base_provider::remove_item_meta(const std::string &api_path,
}
void base_provider::remove_unmatched_source_files(stop_type &stop_requested) {
REPERTORY_USES_FUNCTION_NAME();
if (is_read_only()) {
return;
}
@ -788,20 +787,18 @@ auto base_provider::start(api_item_added_callback api_item_added,
api_item_added_(true, dir);
}
auto online{false};
auto unmount_requested{false};
const auto get_stop_requested = [&unmount_requested]() -> bool {
return unmount_requested || app_config::get_stop_requested();
auto stop_requested{false};
const auto get_stop_requested = [&stop_requested]() -> bool {
return stop_requested || app_config::get_stop_requested();
};
{
const auto &cfg = get_config();
repertory::event_consumer consumer(
"unmount_requested", [&unmount_requested](const i_event & /* evt */) {
unmount_requested = true;
});
unmount_requested::name,
[&stop_requested](const i_event & /* evt */) { stop_requested = true; });
auto online{false};
for (std::uint16_t idx = 0U; not online && not get_stop_requested() &&
(idx < cfg.get_online_check_retry_secs());
++idx) {
@ -815,7 +812,6 @@ auto base_provider::start(api_item_added_callback api_item_added,
cfg.get_host_config().api_port);
std::this_thread::sleep_for(1s);
}
}
if (not online || get_stop_requested()) {
return false;

View File

@ -27,8 +27,10 @@
#include "events/types/service_start_end.hpp"
#include "events/types/service_stop_begin.hpp"
#include "events/types/service_stop_end.hpp"
#include "events/types/unmount_requested.hpp"
#include "utils/base64.hpp"
#include "utils/error_utils.hpp"
#include "utils/string.hpp"
namespace repertory {
server::server(app_config &config) : config_(config) {}
@ -150,13 +152,13 @@ void server::start() {
server_->set_exception_handler([](const httplib::Request &req,
httplib::Response &res,
std::exception_ptr ep) {
std::exception_ptr ptr) {
json data = {{"path", req.path}};
try {
std::rethrow_exception(ep);
std::rethrow_exception(ptr);
} catch (std::exception &e) {
data["error"] = e.what() ? e.what() : "unknown error";
data["error"] = (e.what() == nullptr) ? "unknown error" : e.what();
utils::error::raise_error(function_name, e,
"failed request: " + req.path);
} catch (...) {