refactor event system
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
This commit is contained in:
@ -22,7 +22,6 @@
|
|||||||
#ifndef REPERTORY_INCLUDE_APP_CONFIG_HPP_
|
#ifndef REPERTORY_INCLUDE_APP_CONFIG_HPP_
|
||||||
#define REPERTORY_INCLUDE_APP_CONFIG_HPP_
|
#define REPERTORY_INCLUDE_APP_CONFIG_HPP_
|
||||||
|
|
||||||
#include "events/event.hpp"
|
|
||||||
#include "types/remote.hpp"
|
#include "types/remote.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
@ -32,26 +31,26 @@ private:
|
|||||||
static stop_type stop_requested;
|
static stop_type stop_requested;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] static auto default_agent_name(const provider_type &prov)
|
[[nodiscard]] static auto
|
||||||
-> std::string;
|
default_agent_name(const provider_type &prov) -> std::string;
|
||||||
|
|
||||||
[[nodiscard]] static auto default_api_port(const provider_type &prov)
|
[[nodiscard]] static auto
|
||||||
-> std::uint16_t;
|
default_api_port(const provider_type &prov) -> std::uint16_t;
|
||||||
|
|
||||||
[[nodiscard]] static auto default_data_directory(const provider_type &prov)
|
[[nodiscard]] static auto
|
||||||
-> std::string;
|
default_data_directory(const provider_type &prov) -> std::string;
|
||||||
|
|
||||||
[[nodiscard]] static auto default_remote_api_port(const provider_type &prov)
|
[[nodiscard]] static auto
|
||||||
-> std::uint16_t;
|
default_remote_api_port(const provider_type &prov) -> std::uint16_t;
|
||||||
|
|
||||||
[[nodiscard]] static auto default_rpc_port(const provider_type &prov)
|
[[nodiscard]] static auto
|
||||||
-> std::uint16_t;
|
default_rpc_port(const provider_type &prov) -> std::uint16_t;
|
||||||
|
|
||||||
[[nodiscard]] static auto get_provider_display_name(const provider_type &prov)
|
[[nodiscard]] static auto
|
||||||
-> std::string;
|
get_provider_display_name(const provider_type &prov) -> std::string;
|
||||||
|
|
||||||
[[nodiscard]] static auto get_provider_name(const provider_type &prov)
|
[[nodiscard]] static auto
|
||||||
-> std::string;
|
get_provider_name(const provider_type &prov) -> std::string;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] static auto get_stop_requested() -> bool;
|
[[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_task_wait_ms() const -> std::uint16_t;
|
||||||
|
|
||||||
[[nodiscard]] auto get_value_by_name(const std::string &name) const
|
[[nodiscard]] auto
|
||||||
-> std::string;
|
get_value_by_name(const std::string &name) const -> std::string;
|
||||||
|
|
||||||
[[nodiscard]] auto get_version() const -> std::uint64_t;
|
[[nodiscard]] auto get_version() const -> std::uint64_t;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
|
|
||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "utils/path.hpp"
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
class app_config;
|
class app_config;
|
||||||
@ -51,8 +51,8 @@ private:
|
|||||||
std::string mount_location_;
|
std::string mount_location_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool atime_enabled_ = true;
|
bool atime_enabled_{true};
|
||||||
bool console_enabled_ = false;
|
bool console_enabled_{false};
|
||||||
std::optional<gid_t> forced_gid_;
|
std::optional<gid_t> forced_gid_;
|
||||||
std::optional<uid_t> forced_uid_;
|
std::optional<uid_t> forced_uid_;
|
||||||
std::optional<mode_t> forced_umask_;
|
std::optional<mode_t> forced_umask_;
|
||||||
@ -61,7 +61,7 @@ private:
|
|||||||
static auto instance() -> fuse_base &;
|
static auto instance() -> fuse_base &;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct fuse_operations fuse_ops_{};
|
struct fuse_operations fuse_ops_ {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto
|
||||||
@ -78,9 +78,9 @@ private:
|
|||||||
static void execute_void_callback(std::string_view function_name,
|
static void execute_void_callback(std::string_view function_name,
|
||||||
const std::function<void()> &cb);
|
const std::function<void()> &cb);
|
||||||
|
|
||||||
static auto execute_void_pointer_callback(std::string_view function_name,
|
static auto
|
||||||
const std::function<void *()> &cb)
|
execute_void_pointer_callback(std::string_view function_name,
|
||||||
-> void *;
|
const std::function<void *()> &cb) -> void *;
|
||||||
|
|
||||||
void raise_fuse_event(std::string_view function_name,
|
void raise_fuse_event(std::string_view function_name,
|
||||||
std::string_view api_path, int ret,
|
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,
|
[[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid,
|
||||||
struct fuse_file_info *fi) -> int;
|
struct fuse_file_info *fi) -> int;
|
||||||
#else
|
#else
|
||||||
[[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid)
|
[[nodiscard]] static auto chown_(const char *path, uid_t uid,
|
||||||
-> int;
|
gid_t gid) -> int;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[nodiscard]] static auto create_(const char *path, mode_t mode,
|
[[nodiscard]] static auto create_(const char *path, mode_t mode,
|
||||||
@ -114,8 +114,8 @@ private:
|
|||||||
static void destroy_(void *ptr);
|
static void destroy_(void *ptr);
|
||||||
|
|
||||||
[[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset,
|
[[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset,
|
||||||
off_t length, struct fuse_file_info *fi)
|
off_t length,
|
||||||
-> int;
|
struct fuse_file_info *fi) -> int;
|
||||||
|
|
||||||
#if FUSE_USE_VERSION < 30
|
#if FUSE_USE_VERSION < 30
|
||||||
[[nodiscard]] static auto fgetattr_(const char *path, struct stat *st,
|
[[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 mkdir_(const char *path, mode_t mode) -> int;
|
||||||
|
|
||||||
[[nodiscard]] static auto open_(const char *path, struct fuse_file_info *fi)
|
[[nodiscard]] static auto open_(const char *path,
|
||||||
-> int;
|
struct fuse_file_info *fi) -> int;
|
||||||
|
|
||||||
[[nodiscard]] static auto opendir_(const char *path,
|
[[nodiscard]] static auto opendir_(const char *path,
|
||||||
struct fuse_file_info *fi) -> int;
|
struct fuse_file_info *fi) -> int;
|
||||||
@ -174,8 +174,8 @@ private:
|
|||||||
#else
|
#else
|
||||||
[[nodiscard]] static auto readdir_(const char *path, void *buf,
|
[[nodiscard]] static auto readdir_(const char *path, void *buf,
|
||||||
fuse_fill_dir_t fuse_fill_dir,
|
fuse_fill_dir_t fuse_fill_dir,
|
||||||
off_t offset, struct fuse_file_info *fi)
|
off_t offset,
|
||||||
-> int;
|
struct fuse_file_info *fi) -> int;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[nodiscard]] static auto release_(const char *path,
|
[[nodiscard]] static auto release_(const char *path,
|
||||||
@ -207,8 +207,8 @@ private:
|
|||||||
[[nodiscard]] static auto listxattr_(const char *path, char *buffer,
|
[[nodiscard]] static auto listxattr_(const char *path, char *buffer,
|
||||||
size_t size) -> int;
|
size_t size) -> int;
|
||||||
|
|
||||||
[[nodiscard]] static auto removexattr_(const char *path, const char *name)
|
[[nodiscard]] static auto removexattr_(const char *path,
|
||||||
-> int;
|
const char *name) -> int;
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
[[nodiscard]] static auto setxattr_(const char *path, const char *name,
|
[[nodiscard]] static auto setxattr_(const char *path, const char *name,
|
||||||
@ -217,18 +217,17 @@ private:
|
|||||||
|
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
[[nodiscard]] static auto setxattr_(const char *path, const char *name,
|
[[nodiscard]] static auto setxattr_(const char *path, const char *name,
|
||||||
const char *value, size_t size, int flags)
|
const char *value, size_t size,
|
||||||
-> int;
|
int flags) -> int;
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
#endif // HAS_SETXATTR
|
#endif // HAS_SETXATTR
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
[[nodiscard]] static auto setattr_x_(const char *path, struct setattr_x *attr)
|
[[nodiscard]] static auto setattr_x_(const char *path,
|
||||||
-> int;
|
struct setattr_x *attr) -> int;
|
||||||
|
|
||||||
[[nodiscard]] static auto setbkuptime_(const char *path,
|
[[nodiscard]] static auto
|
||||||
const struct timespec *bkuptime)
|
setbkuptime_(const char *path, const struct timespec *bkuptime) -> int;
|
||||||
-> int;
|
|
||||||
|
|
||||||
[[nodiscard]] static auto setchgtime_(const char *path,
|
[[nodiscard]] static auto setchgtime_(const char *path,
|
||||||
const struct timespec *chgtime) -> int;
|
const struct timespec *chgtime) -> int;
|
||||||
@ -238,12 +237,12 @@ private:
|
|||||||
|
|
||||||
[[nodiscard]] static auto setvolname_(const char *volname) -> int;
|
[[nodiscard]] static auto setvolname_(const char *volname) -> int;
|
||||||
|
|
||||||
[[nodiscard]] static auto statfs_x_(const char *path, struct statfs *stbuf)
|
[[nodiscard]] static auto statfs_x_(const char *path,
|
||||||
-> int;
|
struct statfs *stbuf) -> int;
|
||||||
|
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
[[nodiscard]] static auto statfs_(const char *path, struct statvfs *stbuf)
|
[[nodiscard]] static auto statfs_(const char *path,
|
||||||
-> int;
|
struct statvfs *stbuf) -> int;
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
@ -269,8 +268,8 @@ private:
|
|||||||
struct fuse_file_info *fi) -> int;
|
struct fuse_file_info *fi) -> int;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
[[nodiscard]] virtual auto access_impl(std::string /*api_path*/, int /*mask*/)
|
[[nodiscard]] virtual auto access_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
int /*mask*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,10 +281,9 @@ protected:
|
|||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
[[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
mode_t /*mode*/,
|
chmod_impl(std::string /*api_path*/, mode_t /*mode*/,
|
||||||
struct fuse_file_info * /*fi*/)
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -296,10 +294,9 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
[[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/,
|
[[nodiscard]] virtual auto
|
||||||
gid_t /*gid*/,
|
chown_impl(std::string /*api_path*/, uid_t /*uid*/, gid_t /*gid*/,
|
||||||
struct fuse_file_info * /*fi*/)
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -309,10 +306,9 @@ protected:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[nodiscard]] virtual auto create_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
mode_t /*mode*/,
|
create_impl(std::string /*api_path*/, mode_t /*mode*/,
|
||||||
struct fuse_file_info * /*fi*/)
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,48 +316,43 @@ protected:
|
|||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto
|
||||||
fallocate_impl(std::string /*api_path*/, int /*mode*/, off_t /*offset*/,
|
fallocate_impl(std::string /*api_path*/, int /*mode*/, off_t /*offset*/,
|
||||||
off_t /*length*/, struct fuse_file_info * /*fi*/)
|
off_t /*length*/,
|
||||||
-> api_error {
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto fgetattr_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
struct stat * /*st*/,
|
fgetattr_impl(std::string /*api_path*/, struct stat * /*st*/,
|
||||||
struct fuse_file_info * /*fi*/)
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
[[nodiscard]] virtual auto fsetattr_x_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
struct setattr_x * /*attr*/,
|
fsetattr_x_impl(std::string /*api_path*/, struct setattr_x * /*attr*/,
|
||||||
struct fuse_file_info * /*fi*/)
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
[[nodiscard]] virtual auto fsync_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
int /*datasync*/,
|
fsync_impl(std::string /*api_path*/, int /*datasync*/,
|
||||||
struct fuse_file_info * /*fi*/)
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FUSE_USE_VERSION < 30
|
#if FUSE_USE_VERSION < 30
|
||||||
[[nodiscard]] virtual auto ftruncate_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
off_t /*size*/,
|
ftruncate_impl(std::string /*api_path*/, off_t /*size*/,
|
||||||
struct fuse_file_info * /*fi*/)
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
[[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
struct stat * /*st*/,
|
getattr_impl(std::string /*api_path*/, struct stat * /*st*/,
|
||||||
struct fuse_file_info * /*fi*/)
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -372,17 +363,16 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
[[nodiscard]] virtual auto getxtimes_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
struct timespec * /*bkuptime*/,
|
getxtimes_impl(std::string /*api_path*/, struct timespec * /*bkuptime*/,
|
||||||
struct timespec * /*crtime*/)
|
struct timespec * /*crtime*/) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
virtual auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg)
|
virtual auto init_impl(struct fuse_conn_info *conn,
|
||||||
-> void *;
|
struct fuse_config *cfg) -> void *;
|
||||||
#else
|
#else
|
||||||
virtual auto init_impl(struct fuse_conn_info *conn) -> void *;
|
virtual auto init_impl(struct fuse_conn_info *conn) -> void *;
|
||||||
#endif
|
#endif
|
||||||
@ -392,15 +382,15 @@ protected:
|
|||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto open_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
struct fuse_file_info * /*fi*/)
|
open_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto opendir_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
struct fuse_file_info * /*fi*/)
|
opendir_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,8 +405,8 @@ protected:
|
|||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto
|
||||||
readdir_impl(std::string /*api_path*/, void * /*buf*/,
|
readdir_impl(std::string /*api_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*/, fuse_readdir_flags /*flags*/)
|
struct fuse_file_info * /*fi*/,
|
||||||
-> api_error {
|
fuse_readdir_flags /*flags*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -428,15 +418,15 @@ protected:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[nodiscard]] virtual auto release_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
struct fuse_file_info * /*fi*/)
|
release_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto releasedir_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
struct fuse_file_info * /*fi*/)
|
releasedir_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,9 +437,9 @@ protected:
|
|||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
[[nodiscard]] virtual auto rename_impl(std::string /*from_api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
std::string /*to_api_path*/)
|
rename_impl(std::string /*from_api_path*/,
|
||||||
-> api_error {
|
std::string /*to_api_path*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -469,8 +459,8 @@ protected:
|
|||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto
|
||||||
getxattr_impl(std::string /*api_path*/, const char * /*name*/,
|
getxattr_impl(std::string /*api_path*/, const char * /*name*/,
|
||||||
char * /*value*/, size_t /*size*/, int & /*attribute_size*/)
|
char * /*value*/, size_t /*size*/,
|
||||||
-> api_error {
|
int & /*attribute_size*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
@ -481,9 +471,9 @@ protected:
|
|||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto removexattr_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
const char * /*name*/)
|
removexattr_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
const char * /*name*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,19 +486,20 @@ protected:
|
|||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto setxattr_impl(std::string /*api_path*/,
|
||||||
setxattr_impl(std::string /*api_path*/, const char * /*name*/,
|
const char * /*name*/,
|
||||||
const char * /*value*/, size_t /*size*/, int /*flags*/)
|
const char * /*value*/,
|
||||||
-> api_error {
|
size_t /*size*/,
|
||||||
|
int /*flags*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
#endif // HAS_SETXATTR
|
#endif // HAS_SETXATTR
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
[[nodiscard]] virtual auto setattr_x_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
struct setattr_x * /*attr*/)
|
setattr_x_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
struct setattr_x * /*attr*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,40 +510,39 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto
|
||||||
setchgtime_impl(std::string /*api_path*/, const struct timespec * /*chgtime*/)
|
setchgtime_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
const struct timespec * /*chgtime*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto setcrtime_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
const struct timespec * /*crtime*/)
|
setcrtime_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
const struct timespec * /*crtime*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto setvolname_impl(const char * /*volname*/)
|
[[nodiscard]] virtual auto
|
||||||
-> api_error {
|
setvolname_impl(const char * /*volname*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual auto statfs_x_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
struct statfs * /*stbuf*/)
|
statfs_x_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
struct statfs * /*stbuf*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
[[nodiscard]] virtual auto statfs_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
struct statvfs * /*stbuf*/)
|
statfs_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
struct statvfs * /*stbuf*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
[[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
off_t /*size*/,
|
truncate_impl(std::string /*api_path*/, off_t /*size*/,
|
||||||
struct fuse_file_info * /*fi*/)
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -562,22 +552,21 @@ protected:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[nodiscard]] virtual auto unlink_impl(std::string /*api_path*/)
|
[[nodiscard]] virtual auto
|
||||||
-> api_error {
|
unlink_impl(std::string /*api_path*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
[[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
const struct timespec /*tv*/[2],
|
utimens_impl(std::string /*api_path*/, const struct timespec /*tv*/[2],
|
||||||
struct fuse_file_info * /*fi*/)
|
struct fuse_file_info * /*fi*/) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
[[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/,
|
[[nodiscard]] virtual auto
|
||||||
const struct timespec /*tv*/[2])
|
utimens_impl(std::string /*api_path*/,
|
||||||
-> api_error {
|
const struct timespec /*tv*/[2]) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -585,8 +574,8 @@ protected:
|
|||||||
[[nodiscard]] virtual auto
|
[[nodiscard]] virtual auto
|
||||||
write_impl(std::string /*api_path*/, const char * /*buffer*/,
|
write_impl(std::string /*api_path*/, const char * /*buffer*/,
|
||||||
size_t /*write_size*/, off_t /*write_offset*/,
|
size_t /*write_size*/, off_t /*write_offset*/,
|
||||||
struct fuse_file_info * /*fi*/, std::size_t & /*bytes_written*/)
|
struct fuse_file_info * /*fi*/,
|
||||||
-> api_error {
|
std::size_t & /*bytes_written*/) -> api_error {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,37 +22,10 @@
|
|||||||
#ifndef REPERTORY_INCLUDE_EVENTS_EVENTS_HPP_
|
#ifndef REPERTORY_INCLUDE_EVENTS_EVENTS_HPP_
|
||||||
#define REPERTORY_INCLUDE_EVENTS_EVENTS_HPP_
|
#define REPERTORY_INCLUDE_EVENTS_EVENTS_HPP_
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "utils/utils.hpp"
|
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
// clang-format off
|
// 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,
|
E_SIMPLE2(download_restored, info,
|
||||||
std::string, api_path, ap, E_FROM_STRING,
|
std::string, api_path, ap, E_FROM_STRING,
|
||||||
std::string, dest_path, dest, E_FROM_STRING
|
std::string, dest_path, dest, E_FROM_STRING
|
||||||
|
@ -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_
|
79
repertory/librepertory/include/events/types/download_end.hpp
Normal file
79
repertory/librepertory/include/events/types/download_end.hpp
Normal 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_
|
@ -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_
|
@ -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_
|
@ -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_
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
|
#include "events/types/unmount_requested.hpp"
|
||||||
|
#include "events/types/unmount_result.hpp"
|
||||||
#include "initialize.hpp"
|
#include "initialize.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "utils/collection.hpp"
|
#include "utils/collection.hpp"
|
||||||
@ -116,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, struct fuse_file_info *fi)
|
auto fuse_base::chmod_(const char *path, mode_t mode,
|
||||||
-> int {
|
struct fuse_file_info *fi) -> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
return instance().execute_callback(
|
||||||
@ -184,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);
|
||||||
@ -194,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);
|
||||||
@ -332,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, struct fuse_config *cfg)
|
auto fuse_base::init_(struct fuse_conn_info *conn,
|
||||||
-> void * {
|
struct fuse_config *cfg) -> 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 * {
|
||||||
@ -406,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
|
||||||
@ -475,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, fuse_readdir_flags flags)
|
struct fuse_file_info *fi,
|
||||||
-> int {
|
fuse_readdir_flags flags) -> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
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)
|
auto fuse_base::releasedir_(const char *path,
|
||||||
-> int {
|
struct fuse_file_info *fi) -> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
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
|
#if FUSE_USE_VERSION >= 30
|
||||||
auto fuse_base::rename_(const char *from, const char *to, unsigned int flags)
|
auto fuse_base::rename_(const char *from, const char *to,
|
||||||
-> int {
|
unsigned int flags) -> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
return instance().execute_callback(
|
||||||
@ -748,9 +750,11 @@ auto fuse_base::setxattr_(const char *path, const char *name, const char *value,
|
|||||||
#endif // HAS_SETXATTR
|
#endif // HAS_SETXATTR
|
||||||
|
|
||||||
void fuse_base::shutdown() {
|
void fuse_base::shutdown() {
|
||||||
const auto res = unmount(get_mount_location());
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
event_system2::instance().raise<unmount_result>(get_mount_location(),
|
|
||||||
std::to_string(res));
|
auto res = unmount(get_mount_location());
|
||||||
|
event_system2::instance().raise<unmount_result>(function_name,
|
||||||
|
get_mount_location(), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#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)
|
auto fuse_base::setbkuptime_(const char *path,
|
||||||
-> int {
|
const struct timespec *bkuptime) -> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
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)
|
auto fuse_base::setchgtime_(const char *path,
|
||||||
-> int {
|
const struct timespec *chgtime) -> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
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)
|
auto fuse_base::setcrtime_(const char *path,
|
||||||
-> int {
|
const struct timespec *crtime) -> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return instance().execute_callback(
|
return instance().execute_callback(
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "events/types/drive_mounted.hpp"
|
#include "events/types/drive_mounted.hpp"
|
||||||
#include "events/types/drive_unmount_pending.hpp"
|
#include "events/types/drive_unmount_pending.hpp"
|
||||||
#include "events/types/drive_unmounted.hpp"
|
#include "events/types/drive_unmounted.hpp"
|
||||||
|
#include "events/types/unmount_requested.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "rpc/server/server.hpp"
|
#include "rpc/server/server.hpp"
|
||||||
#include "types/remote.hpp"
|
#include "types/remote.hpp"
|
||||||
@ -42,8 +43,8 @@
|
|||||||
#include "utils/utils.hpp"
|
#include "utils/utils.hpp"
|
||||||
|
|
||||||
namespace repertory::remote_fuse {
|
namespace repertory::remote_fuse {
|
||||||
auto remote_fuse_drive::access_impl(std::string api_path, int mask)
|
auto remote_fuse_drive::access_impl(std::string api_path,
|
||||||
-> api_error {
|
int mask) -> api_error {
|
||||||
return utils::to_api_error(
|
return utils::to_api_error(
|
||||||
remote_instance_->fuse_access(api_path.c_str(), mask));
|
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*/)
|
struct fuse_file_info * /*f_info*/)
|
||||||
-> api_error {
|
-> api_error {
|
||||||
#else
|
#else
|
||||||
auto remote_fuse_drive::chmod_impl(std::string api_path, mode_t mode)
|
auto remote_fuse_drive::chmod_impl(std::string api_path,
|
||||||
-> api_error {
|
mode_t mode) -> api_error {
|
||||||
#endif
|
#endif
|
||||||
return utils::to_api_error(remote_instance_->fuse_chmod(
|
return utils::to_api_error(remote_instance_->fuse_chmod(
|
||||||
api_path.c_str(), static_cast<remote::file_mode>(mode)));
|
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*/)
|
struct fuse_file_info * /*f_info*/)
|
||||||
-> api_error {
|
-> api_error {
|
||||||
#else
|
#else
|
||||||
auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid)
|
auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid,
|
||||||
-> api_error {
|
gid_t gid) -> api_error {
|
||||||
#endif
|
#endif
|
||||||
return utils::to_api_error(
|
return utils::to_api_error(
|
||||||
remote_instance_->fuse_chown(api_path.c_str(), uid, gid));
|
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);
|
fuse_base::destroy_impl(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto remote_fuse_drive::fgetattr_impl(std::string api_path,
|
auto remote_fuse_drive::fgetattr_impl(
|
||||||
struct stat *unix_st,
|
std::string api_path, struct stat *unix_st,
|
||||||
struct fuse_file_info *f_info)
|
struct fuse_file_info *f_info) -> api_error {
|
||||||
-> api_error {
|
|
||||||
remote::stat r_stat{};
|
remote::stat r_stat{};
|
||||||
auto directory = false;
|
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*/)
|
struct fuse_file_info * /*f_info*/)
|
||||||
-> api_error {
|
-> api_error {
|
||||||
#else
|
#else
|
||||||
auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st)
|
auto remote_fuse_drive::getattr_impl(std::string api_path,
|
||||||
-> api_error {
|
struct stat *unix_st) -> api_error {
|
||||||
#endif
|
#endif
|
||||||
bool directory = false;
|
bool directory = false;
|
||||||
remote::stat r_stat{};
|
remote::stat r_stat{};
|
||||||
@ -269,8 +269,8 @@ auto remote_fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto remote_fuse_drive::mkdir_impl(std::string api_path, mode_t mode)
|
auto remote_fuse_drive::mkdir_impl(std::string api_path,
|
||||||
-> api_error {
|
mode_t mode) -> api_error {
|
||||||
return utils::to_api_error(remote_instance_->fuse_mkdir(
|
return utils::to_api_error(remote_instance_->fuse_mkdir(
|
||||||
api_path.c_str(), static_cast<remote::file_mode>(mode)));
|
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));
|
f_info->fh));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto remote_fuse_drive::opendir_impl(std::string api_path,
|
auto remote_fuse_drive::opendir_impl(
|
||||||
struct fuse_file_info *f_info)
|
std::string api_path, struct fuse_file_info *f_info) -> api_error {
|
||||||
-> api_error {
|
|
||||||
if ((f_info->flags & O_APPEND) == O_APPEND ||
|
if ((f_info->flags & O_APPEND) == O_APPEND ||
|
||||||
(f_info->flags & O_EXCL) == O_EXCL) {
|
(f_info->flags & O_EXCL) == O_EXCL) {
|
||||||
return api_error::directory_exists;
|
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
|
#if FUSE_USE_VERSION >= 30
|
||||||
auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf,
|
auto remote_fuse_drive::readdir_impl(
|
||||||
fuse_fill_dir_t fuse_fill_dir,
|
std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
|
||||||
off_t offset,
|
off_t offset, struct fuse_file_info *f_info,
|
||||||
struct fuse_file_info *f_info,
|
fuse_readdir_flags /*flags*/) -> api_error {
|
||||||
fuse_readdir_flags /*flags*/)
|
|
||||||
-> api_error {
|
|
||||||
#else
|
#else
|
||||||
auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf,
|
auto remote_fuse_drive::readdir_impl(
|
||||||
fuse_fill_dir_t fuse_fill_dir,
|
std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
|
||||||
off_t offset,
|
off_t offset, struct fuse_file_info *f_info) -> api_error {
|
||||||
struct fuse_file_info *f_info)
|
|
||||||
-> api_error {
|
|
||||||
#endif
|
#endif
|
||||||
std::string item_path;
|
std::string item_path;
|
||||||
int res = 0;
|
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);
|
return utils::to_api_error(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto remote_fuse_drive::release_impl(std::string api_path,
|
auto remote_fuse_drive::release_impl(
|
||||||
struct fuse_file_info *f_info)
|
std::string api_path, struct fuse_file_info *f_info) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return utils::to_api_error(
|
return utils::to_api_error(
|
||||||
remote_instance_->fuse_release(api_path.c_str(), f_info->fh));
|
remote_instance_->fuse_release(api_path.c_str(), f_info->fh));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto remote_fuse_drive::releasedir_impl(std::string api_path,
|
auto remote_fuse_drive::releasedir_impl(
|
||||||
struct fuse_file_info *f_info)
|
std::string api_path, struct fuse_file_info *f_info) -> api_error {
|
||||||
-> api_error {
|
|
||||||
return utils::to_api_error(
|
return utils::to_api_error(
|
||||||
remote_instance_->fuse_releasedir(api_path.c_str(), f_info->fh));
|
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);
|
return utils::to_api_error(res);
|
||||||
}
|
}
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
auto remote_fuse_drive::statfs_impl(std::string api_path, struct statvfs *stbuf)
|
auto remote_fuse_drive::statfs_impl(std::string api_path,
|
||||||
-> api_error {
|
struct statvfs *stbuf) -> api_error {
|
||||||
auto res = statvfs(config_.get_data_directory().c_str(), stbuf);
|
auto res = statvfs(config_.get_data_directory().c_str(), stbuf);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
remote::statfs r_stat{};
|
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*/)
|
struct fuse_file_info * /*f_info*/)
|
||||||
-> api_error {
|
-> api_error {
|
||||||
#else
|
#else
|
||||||
auto remote_fuse_drive::truncate_impl(std::string api_path, off_t size)
|
auto remote_fuse_drive::truncate_impl(std::string api_path,
|
||||||
-> api_error {
|
off_t size) -> api_error {
|
||||||
#endif
|
#endif
|
||||||
return utils::to_api_error(remote_instance_->fuse_truncate(
|
return utils::to_api_error(remote_instance_->fuse_truncate(
|
||||||
api_path.c_str(), static_cast<remote::file_offset>(size)));
|
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
|
#if FUSE_USE_VERSION >= 30
|
||||||
auto remote_fuse_drive::utimens_impl(std::string api_path,
|
auto remote_fuse_drive::utimens_impl(
|
||||||
const struct timespec tv[2],
|
std::string api_path, const struct timespec tv[2],
|
||||||
struct fuse_file_info * /*f_info*/)
|
struct fuse_file_info * /*f_info*/) -> api_error {
|
||||||
-> api_error {
|
|
||||||
#else
|
#else
|
||||||
auto remote_fuse_drive::utimens_impl(std::string api_path,
|
auto remote_fuse_drive::utimens_impl(std::string api_path,
|
||||||
const struct timespec tv[2]) -> api_error {
|
const struct timespec tv[2]) -> api_error {
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "events/event_system2.hpp"
|
#include "events/event_system2.hpp"
|
||||||
#include "events/types/drive_mount_failed.hpp"
|
#include "events/types/drive_mount_failed.hpp"
|
||||||
#include "events/types/drive_mount_result.hpp"
|
#include "events/types/drive_mount_result.hpp"
|
||||||
|
#include "events/types/unmount_requested.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "rpc/server/server.hpp"
|
#include "rpc/server/server.hpp"
|
||||||
#include "utils/collection.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,
|
UINT32 granted_access, UINT32 attributes,
|
||||||
PSECURITY_DESCRIPTOR /*descriptor*/,
|
PSECURITY_DESCRIPTOR /*descriptor*/,
|
||||||
UINT64 allocation_size, PVOID * /*file_node*/,
|
UINT64 allocation_size, PVOID * /*file_node*/,
|
||||||
PVOID *file_desc, OpenFileInfo *ofi)
|
PVOID *file_desc,
|
||||||
-> NTSTATUS {
|
OpenFileInfo *ofi) -> NTSTATUS {
|
||||||
remote::file_info fi{};
|
remote::file_info fi{};
|
||||||
std::string normalized_name;
|
std::string normalized_name;
|
||||||
BOOLEAN exists = 0;
|
BOOLEAN exists = 0;
|
||||||
@ -163,10 +164,9 @@ auto remote_winfsp_drive::GetFileInfo(PVOID /*file_node*/, PVOID file_desc,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto remote_winfsp_drive::GetSecurityByName(PWSTR file_name, PUINT32 attributes,
|
auto remote_winfsp_drive::GetSecurityByName(
|
||||||
PSECURITY_DESCRIPTOR descriptor,
|
PWSTR file_name, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor,
|
||||||
SIZE_T *descriptor_size)
|
SIZE_T *descriptor_size) -> NTSTATUS {
|
||||||
-> NTSTATUS {
|
|
||||||
std::wstring string_descriptor;
|
std::wstring string_descriptor;
|
||||||
std::uint64_t sds = (descriptor_size == nullptr) ? 0 : *descriptor_size;
|
std::uint64_t sds = (descriptor_size == nullptr) ? 0 : *descriptor_size;
|
||||||
auto ret = remote_instance_->winfsp_get_security_by_name(
|
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,
|
auto remote_winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
|
||||||
UINT32 granted_access, PVOID * /*file_node*/,
|
UINT32 granted_access, PVOID * /*file_node*/,
|
||||||
PVOID *file_desc, OpenFileInfo *ofi)
|
PVOID *file_desc,
|
||||||
-> NTSTATUS {
|
OpenFileInfo *ofi) -> NTSTATUS {
|
||||||
remote::file_info fi{};
|
remote::file_info fi{};
|
||||||
std::string normalize_name;
|
std::string normalize_name;
|
||||||
auto ret =
|
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,
|
auto remote_winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc,
|
||||||
UINT32 attributes,
|
UINT32 attributes,
|
||||||
BOOLEAN replace_attributes,
|
BOOLEAN replace_attributes,
|
||||||
UINT64 allocation_size, FileInfo *file_info)
|
UINT64 allocation_size,
|
||||||
-> NTSTATUS {
|
FileInfo *file_info) -> NTSTATUS {
|
||||||
remote::file_info info{};
|
remote::file_info info{};
|
||||||
auto ret = remote_instance_->winfsp_overwrite(
|
auto ret = remote_instance_->winfsp_overwrite(
|
||||||
file_desc, attributes, replace_attributes, allocation_size, &info);
|
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,
|
UINT32 attributes, UINT64 creation_time,
|
||||||
UINT64 last_access_time,
|
UINT64 last_access_time,
|
||||||
UINT64 last_write_time,
|
UINT64 last_write_time,
|
||||||
UINT64 change_time, FileInfo *file_info)
|
UINT64 change_time,
|
||||||
-> NTSTATUS {
|
FileInfo *file_info) -> NTSTATUS {
|
||||||
remote::file_info fi{};
|
remote::file_info fi{};
|
||||||
auto ret = remote_instance_->winfsp_set_basic_info(
|
auto ret = remote_instance_->winfsp_set_basic_info(
|
||||||
file_desc, attributes, creation_time, last_access_time, last_write_time,
|
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,
|
auto remote_winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc,
|
||||||
PVOID buffer, UINT64 offset, ULONG length,
|
PVOID buffer, UINT64 offset, ULONG length,
|
||||||
BOOLEAN write_to_end, BOOLEAN constrained_io,
|
BOOLEAN write_to_end, BOOLEAN constrained_io,
|
||||||
PULONG bytes_transferred, FileInfo *file_info)
|
PULONG bytes_transferred,
|
||||||
-> NTSTATUS {
|
FileInfo *file_info) -> NTSTATUS {
|
||||||
remote::file_info fi{};
|
remote::file_info fi{};
|
||||||
auto ret = remote_instance_->winfsp_write(
|
auto ret = remote_instance_->winfsp_write(
|
||||||
file_desc, buffer, offset, length, write_to_end, constrained_io,
|
file_desc, buffer, offset, length, write_to_end, constrained_io,
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "events/types/drive_mounted.hpp"
|
#include "events/types/drive_mounted.hpp"
|
||||||
#include "events/types/drive_unmount_pending.hpp"
|
#include "events/types/drive_unmount_pending.hpp"
|
||||||
#include "events/types/drive_unmounted.hpp"
|
#include "events/types/drive_unmounted.hpp"
|
||||||
|
#include "events/types/unmount_requested.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "providers/i_provider.hpp"
|
#include "providers/i_provider.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
@ -99,8 +100,8 @@ auto winfsp_drive::handle_error(std::string_view function_name,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/, PWSTR * /*Argv*/)
|
auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/,
|
||||||
-> NTSTATUS {
|
PWSTR * /*Argv*/) -> NTSTATUS {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
auto mount_location = utils::string::to_lower(
|
auto mount_location = utils::string::to_lower(
|
||||||
@ -483,10 +484,9 @@ auto winfsp_drive::get_item_meta(const std::string &api_path,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto winfsp_drive::get_security_by_name(PWSTR file_name, PUINT32 attributes,
|
auto winfsp_drive::get_security_by_name(
|
||||||
PSECURITY_DESCRIPTOR descriptor,
|
PWSTR file_name, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor,
|
||||||
std::uint64_t *descriptor_size)
|
std::uint64_t *descriptor_size) -> NTSTATUS {
|
||||||
-> NTSTATUS {
|
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::path::create_api_path(utils::string::to_utf8(file_name));
|
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,
|
auto winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc,
|
||||||
UINT32 attributes, BOOLEAN replace_attributes,
|
UINT32 attributes, BOOLEAN replace_attributes,
|
||||||
UINT64 /*allocation_size*/, FileInfo *file_info)
|
UINT64 /*allocation_size*/,
|
||||||
-> NTSTATUS {
|
FileInfo *file_info) -> NTSTATUS {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
std::string api_path;
|
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,
|
auto winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, PVOID buffer,
|
||||||
UINT64 offset, ULONG length, PULONG bytes_transferred)
|
UINT64 offset, ULONG length,
|
||||||
-> NTSTATUS {
|
PULONG bytes_transferred) -> NTSTATUS {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
*bytes_transferred = 0U;
|
*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,
|
auto winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
||||||
PWSTR /*pattern*/, PWSTR marker, PVOID buffer,
|
PWSTR /*pattern*/, PWSTR marker, PVOID buffer,
|
||||||
ULONG buffer_length, PULONG bytes_transferred)
|
ULONG buffer_length,
|
||||||
-> NTSTATUS {
|
PULONG bytes_transferred) -> NTSTATUS {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
std::string api_path;
|
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,
|
auto winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc,
|
||||||
UINT32 attributes, UINT64 creation_time,
|
UINT32 attributes, UINT64 creation_time,
|
||||||
UINT64 last_access_time, UINT64 last_write_time,
|
UINT64 last_access_time, UINT64 last_write_time,
|
||||||
UINT64 change_time, FileInfo *file_info)
|
UINT64 change_time,
|
||||||
-> NTSTATUS {
|
FileInfo *file_info) -> NTSTATUS {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
std::string api_path;
|
std::string api_path;
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "file_manager/open_file.hpp"
|
#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/cache_size_mgr.hpp"
|
||||||
#include "file_manager/file_manager.hpp"
|
#include "file_manager/file_manager.hpp"
|
||||||
#include "file_manager/i_upload_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(); }
|
open_file::~open_file() { close(); }
|
||||||
|
|
||||||
auto open_file::adjust_cache_size(std::uint64_t file_size, bool shrink)
|
auto open_file::adjust_cache_size(std::uint64_t file_size,
|
||||||
-> api_error {
|
bool shrink) -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
if (file_size == get_file_size()) {
|
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,
|
void open_file::download_chunk(std::size_t chunk, bool skip_active,
|
||||||
bool should_reset) {
|
bool should_reset) {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
if (should_reset) {
|
if (should_reset) {
|
||||||
reset_timeout();
|
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()
|
auto data_size = (chunk == read_state.size() - 1U) ? get_last_chunk_size()
|
||||||
: get_chunk_size();
|
: get_chunk_size();
|
||||||
if (get_active_downloads().empty() && (read_state.count() == 0U)) {
|
if (get_active_downloads().empty() && (read_state.count() == 0U)) {
|
||||||
event_system2::instance().raise<download_begin>(get_api_path(),
|
event_system2::instance().raise<download_begin>(
|
||||||
get_source_path());
|
get_api_path(), get_source_path(), function_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_active_downloads()[chunk] = std::make_shared<download>();
|
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())) *
|
static_cast<double>(state.size())) *
|
||||||
100.0;
|
100.0;
|
||||||
event_system2::instance().raise<download_progress>(
|
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_) {
|
if (state.all() && not notified_) {
|
||||||
notified_ = true;
|
notified_ = true;
|
||||||
event_system2::instance().raise<download_end>(
|
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_) {
|
} else if (not notified_) {
|
||||||
notified_ = true;
|
notified_ = true;
|
||||||
event_system2::instance().raise<download_end>(
|
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();
|
lock.unlock();
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
#include "file_manager/ring_buffer_base.hpp"
|
#include "file_manager/ring_buffer_base.hpp"
|
||||||
|
|
||||||
#include "events/event_system2.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 "file_manager/open_file_base.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "providers/i_provider.hpp"
|
#include "providers/i_provider.hpp"
|
||||||
@ -64,8 +67,8 @@ auto ring_buffer_base::check_start() -> api_error {
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system2::instance().raise<download_begin>(get_api_path(),
|
event_system2::instance().raise<download_begin>(
|
||||||
get_source_path());
|
get_api_path(), get_source_path(), function_name);
|
||||||
reader_thread_ =
|
reader_thread_ =
|
||||||
std::make_unique<std::thread>([this]() { reader_thread(); });
|
std::make_unique<std::thread>([this]() { reader_thread(); });
|
||||||
return api_error::success;
|
return api_error::success;
|
||||||
@ -94,8 +97,10 @@ auto ring_buffer_base::close() -> bool {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ring_buffer_base::download_chunk(std::size_t chunk, bool skip_active)
|
auto ring_buffer_base::download_chunk(std::size_t chunk,
|
||||||
-> api_error {
|
bool skip_active) -> api_error {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
unique_mutex_lock chunk_lock(chunk_mtx_);
|
unique_mutex_lock chunk_lock(chunk_mtx_);
|
||||||
const auto unlock_and_notify = [this, &chunk_lock]() {
|
const auto unlock_and_notify = [this, &chunk_lock]() {
|
||||||
chunk_notify_.notify_all();
|
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_)) *
|
static_cast<double>(total_chunks_)) *
|
||||||
100.0;
|
100.0;
|
||||||
event_system2::instance().raise<download_progress>(
|
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() {
|
void ring_buffer_base::reader_thread() {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
unique_mutex_lock chunk_lock(chunk_mtx_);
|
unique_mutex_lock chunk_lock(chunk_mtx_);
|
||||||
auto next_chunk{ring_pos_};
|
auto next_chunk{ring_pos_};
|
||||||
chunk_notify_.notify_all();
|
chunk_notify_.notify_all();
|
||||||
@ -292,7 +299,8 @@ void ring_buffer_base::reader_thread() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
event_system2::instance().raise<download_end>(
|
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) {
|
void ring_buffer_base::reverse(std::size_t count) {
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "events/types/provider_offline.hpp"
|
#include "events/types/provider_offline.hpp"
|
||||||
#include "events/types/provider_upload_begin.hpp"
|
#include "events/types/provider_upload_begin.hpp"
|
||||||
#include "events/types/provider_upload_end.hpp"
|
#include "events/types/provider_upload_end.hpp"
|
||||||
|
#include "events/types/unmount_requested.hpp"
|
||||||
#include "file_manager/cache_size_mgr.hpp"
|
#include "file_manager/cache_size_mgr.hpp"
|
||||||
#include "file_manager/i_file_manager.hpp"
|
#include "file_manager/i_file_manager.hpp"
|
||||||
#include "platform/platform.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,
|
auto base_provider::create_api_file(std::string path, std::string key,
|
||||||
std::uint64_t size, std::uint64_t file_time)
|
std::uint64_t size,
|
||||||
-> api_file {
|
std::uint64_t file_time) -> api_file {
|
||||||
api_file file{};
|
api_file file{};
|
||||||
file.api_path = utils::path::create_api_path(path);
|
file.api_path = utils::path::create_api_path(path);
|
||||||
file.api_parent = utils::path::get_parent_api_path(file.api_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(
|
auto base_provider::create_directory_clone_source_meta(
|
||||||
const std::string &source_api_path, const std::string &api_path)
|
const std::string &source_api_path,
|
||||||
-> api_error {
|
const std::string &api_path) -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
bool exists{};
|
bool exists{};
|
||||||
@ -200,8 +201,8 @@ auto base_provider::create_directory(const std::string &api_path,
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto base_provider::create_file(const std::string &api_path, api_meta_map &meta)
|
auto base_provider::create_file(const std::string &api_path,
|
||||||
-> api_error {
|
api_meta_map &meta) -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -258,9 +259,8 @@ auto base_provider::create_file(const std::string &api_path, api_meta_map &meta)
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto base_provider::get_api_path_from_source(const std::string &source_path,
|
auto base_provider::get_api_path_from_source(
|
||||||
std::string &api_path) const
|
const std::string &source_path, std::string &api_path) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
if (source_path.empty()) {
|
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);
|
return db3_->get_api_path(source_path, api_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto base_provider::get_directory_items(const std::string &api_path,
|
auto base_provider::get_directory_items(
|
||||||
directory_item_list &list) const
|
const std::string &api_path, directory_item_list &list) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -339,10 +338,9 @@ auto base_provider::get_file_size(const std::string &api_path,
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto base_provider::get_filesystem_item(const std::string &api_path,
|
auto base_provider::get_filesystem_item(
|
||||||
bool directory,
|
const std::string &api_path, bool directory,
|
||||||
filesystem_item &fsi) const
|
filesystem_item &fsi) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
bool exists{};
|
bool exists{};
|
||||||
auto res = is_directory(api_path, exists);
|
auto res = is_directory(api_path, exists);
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
@ -375,10 +373,9 @@ auto base_provider::get_filesystem_item(const std::string &api_path,
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto base_provider::get_filesystem_item_and_file(const std::string &api_path,
|
auto base_provider::get_filesystem_item_and_file(
|
||||||
api_file &file,
|
const std::string &api_path, api_file &file,
|
||||||
filesystem_item &fsi) const
|
filesystem_item &fsi) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
auto res = get_file(api_path, file);
|
auto res = get_file(api_path, file);
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
return res;
|
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) {
|
void base_provider::remove_unmatched_source_files(stop_type &stop_requested) {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
if (is_read_only()) {
|
if (is_read_only()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -788,33 +787,30 @@ auto base_provider::start(api_item_added_callback api_item_added,
|
|||||||
api_item_added_(true, dir);
|
api_item_added_(true, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto online{false};
|
auto stop_requested{false};
|
||||||
auto unmount_requested{false};
|
const auto get_stop_requested = [&stop_requested]() -> bool {
|
||||||
const auto get_stop_requested = [&unmount_requested]() -> bool {
|
return stop_requested || app_config::get_stop_requested();
|
||||||
return unmount_requested || app_config::get_stop_requested();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
const auto &cfg = get_config();
|
||||||
const auto &cfg = get_config();
|
|
||||||
|
|
||||||
repertory::event_consumer consumer(
|
repertory::event_consumer consumer(
|
||||||
"unmount_requested", [&unmount_requested](const i_event & /* evt */) {
|
unmount_requested::name,
|
||||||
unmount_requested = true;
|
[&stop_requested](const i_event & /* evt */) { stop_requested = true; });
|
||||||
});
|
|
||||||
|
|
||||||
for (std::uint16_t idx = 0U; not online && not get_stop_requested() &&
|
auto online{false};
|
||||||
(idx < cfg.get_online_check_retry_secs());
|
for (std::uint16_t idx = 0U; not online && not get_stop_requested() &&
|
||||||
++idx) {
|
(idx < cfg.get_online_check_retry_secs());
|
||||||
online = is_online();
|
++idx) {
|
||||||
if (online) {
|
online = is_online();
|
||||||
continue;
|
if (online) {
|
||||||
}
|
continue;
|
||||||
|
|
||||||
event_system2::instance().raise<provider_offline>(
|
|
||||||
function_name, cfg.get_host_config().host_name_or_ip,
|
|
||||||
cfg.get_host_config().api_port);
|
|
||||||
std::this_thread::sleep_for(1s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event_system2::instance().raise<provider_offline>(
|
||||||
|
function_name, cfg.get_host_config().host_name_or_ip,
|
||||||
|
cfg.get_host_config().api_port);
|
||||||
|
std::this_thread::sleep_for(1s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not online || get_stop_requested()) {
|
if (not online || get_stop_requested()) {
|
||||||
|
@ -27,8 +27,10 @@
|
|||||||
#include "events/types/service_start_end.hpp"
|
#include "events/types/service_start_end.hpp"
|
||||||
#include "events/types/service_stop_begin.hpp"
|
#include "events/types/service_stop_begin.hpp"
|
||||||
#include "events/types/service_stop_end.hpp"
|
#include "events/types/service_stop_end.hpp"
|
||||||
|
#include "events/types/unmount_requested.hpp"
|
||||||
#include "utils/base64.hpp"
|
#include "utils/base64.hpp"
|
||||||
#include "utils/error_utils.hpp"
|
#include "utils/error_utils.hpp"
|
||||||
|
#include "utils/string.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
server::server(app_config &config) : config_(config) {}
|
server::server(app_config &config) : config_(config) {}
|
||||||
@ -150,13 +152,13 @@ void server::start() {
|
|||||||
|
|
||||||
server_->set_exception_handler([](const httplib::Request &req,
|
server_->set_exception_handler([](const httplib::Request &req,
|
||||||
httplib::Response &res,
|
httplib::Response &res,
|
||||||
std::exception_ptr ep) {
|
std::exception_ptr ptr) {
|
||||||
json data = {{"path", req.path}};
|
json data = {{"path", req.path}};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::rethrow_exception(ep);
|
std::rethrow_exception(ptr);
|
||||||
} catch (std::exception &e) {
|
} 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,
|
utils::error::raise_error(function_name, e,
|
||||||
"failed request: " + req.path);
|
"failed request: " + req.path);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
Reference in New Issue
Block a user