14 Commits

22 changed files with 544 additions and 568 deletions

View File

@ -161,8 +161,6 @@ public:
void start(); void start();
void stop(); void stop();
void update_used_space(std::uint64_t &used_space) const override;
}; };
} // namespace repertory } // namespace repertory

View File

@ -31,21 +31,20 @@ class i_file_manager {
INTERFACE_SETUP(i_file_manager); INTERFACE_SETUP(i_file_manager);
public: public:
[[nodiscard]] virtual auto [[nodiscard]] virtual auto evict_file(const std::string &api_path)
evict_file(const std::string &api_path) -> bool = 0; -> bool = 0;
[[nodiscard]] virtual auto get_directory_items(
const std::string &api_path) const -> directory_item_list = 0;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
get_open_files() const -> std::unordered_map<std::string, std::size_t> = 0; get_directory_items(const std::string &api_path) const
-> directory_item_list = 0;
[[nodiscard]] virtual auto get_open_files() const
-> std::unordered_map<std::string, std::size_t> = 0;
[[nodiscard]] virtual auto has_no_open_file_handles() const -> bool = 0; [[nodiscard]] virtual auto has_no_open_file_handles() const -> bool = 0;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto is_processing(const std::string &api_path) const
is_processing(const std::string &api_path) const -> bool = 0; -> bool = 0;
virtual void update_used_space(std::uint64_t &used_space) const = 0;
}; };
} // namespace repertory } // namespace repertory

View File

@ -44,25 +44,24 @@ private:
api_item_added_callback api_item_added_; api_item_added_callback api_item_added_;
std::unique_ptr<meta_db> db3_; std::unique_ptr<meta_db> db3_;
i_file_manager *fm_{}; i_file_manager *fm_{};
mutable std::atomic<std::uint64_t> used_space; std::atomic<bool> stop_requested_{false};
private: private:
void remove_deleted_files(bool source_only); void remove_deleted_files(bool source_only);
void update_used_drive_space() const;
protected: protected:
[[nodiscard]] static auto [[nodiscard]] static auto create_api_file(std::string path, std::string key,
create_api_file(std::string path, std::string key, std::uint64_t size, std::uint64_t size,
std::uint64_t file_time) -> api_file; std::uint64_t file_time)
-> api_file;
[[nodiscard]] static auto create_api_file(std::string path, [[nodiscard]] static auto create_api_file(std::string path,
std::uint64_t size, std::uint64_t size,
api_meta_map &meta) -> api_file; api_meta_map &meta) -> api_file;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto create_directory_impl(const std::string &api_path,
create_directory_impl(const std::string &api_path, api_meta_map &meta)
api_meta_map &meta) -> api_error = 0; -> api_error = 0;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
create_file_extra(const std::string & /* api_path */, create_file_extra(const std::string & /* api_path */,
@ -74,8 +73,8 @@ protected:
return api_item_added_; return api_item_added_;
} }
[[nodiscard]] auto [[nodiscard]] auto get_api_item_added() const
get_api_item_added() const -> const api_item_added_callback & { -> const api_item_added_callback & {
return api_item_added_; return api_item_added_;
} }
@ -89,6 +88,8 @@ protected:
[[nodiscard]] auto get_db() -> meta_db & { return *db3_; } [[nodiscard]] auto get_db() -> meta_db & { return *db3_; }
[[nodiscard]] auto get_db() const -> const meta_db & { return *db3_; }
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
get_directory_items_impl(const std::string &api_path, get_directory_items_impl(const std::string &api_path,
directory_item_list &list) const -> api_error = 0; directory_item_list &list) const -> api_error = 0;
@ -99,23 +100,22 @@ protected:
return fm_; return fm_;
} }
[[nodiscard]] virtual auto [[nodiscard]] virtual auto remove_directory_impl(const std::string &api_path)
get_used_drive_space_impl() const -> std::uint64_t = 0; -> api_error = 0;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto remove_file_impl(const std::string &api_path)
remove_directory_impl(const std::string &api_path) -> api_error = 0; -> api_error = 0;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto upload_file_impl(const std::string &api_path,
remove_file_impl(const std::string &api_path) -> api_error = 0; const std::string &source_path,
stop_type &stop_requested)
[[nodiscard]] virtual auto -> api_error = 0;
upload_file_impl(const std::string &api_path, const std::string &source_path,
stop_type &stop_requested) -> api_error = 0;
public: public:
[[nodiscard]] auto create_directory_clone_source_meta( [[nodiscard]] auto
const std::string &source_api_path, create_directory_clone_source_meta(const std::string &source_api_path,
const std::string &api_path) -> api_error override; const std::string &api_path)
-> api_error override;
[[nodiscard]] auto create_directory(const std::string &api_path, [[nodiscard]] auto create_directory(const std::string &api_path,
api_meta_map &meta) -> api_error override; api_meta_map &meta) -> api_error override;
@ -123,76 +123,82 @@ public:
[[nodiscard]] auto create_file(const std::string &api_path, [[nodiscard]] auto create_file(const std::string &api_path,
api_meta_map &meta) -> api_error override; api_meta_map &meta) -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto get_api_path_from_source(const std::string &source_path,
get_api_path_from_source(const std::string &source_path, std::string &api_path) const
std::string &api_path) const -> api_error override; -> api_error override;
[[nodiscard]] auto get_directory_items(const std::string &api_path,
directory_item_list &list) const
-> api_error override;
[[nodiscard]] auto get_file_size(const std::string &api_path,
std::uint64_t &file_size) const
-> api_error override;
[[nodiscard]] auto get_filesystem_item(const std::string &api_path,
bool directory,
filesystem_item &fsi) const
-> api_error override;
[[nodiscard]] auto get_filesystem_item_and_file(const std::string &api_path,
api_file &f,
filesystem_item &fsi) const
-> api_error override;
[[nodiscard]] auto [[nodiscard]] auto
get_directory_items(const std::string &api_path, get_filesystem_item_from_source_path(const std::string &source_path,
directory_item_list &list) const -> api_error override; filesystem_item &fsi) const
-> api_error override;
[[nodiscard]] auto [[nodiscard]] auto get_item_meta(const std::string &api_path,
get_file_size(const std::string &api_path, api_meta_map &meta) const
std::uint64_t &file_size) const -> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto get_item_meta(const std::string &api_path,
get_filesystem_item(const std::string &api_path, bool directory, const std::string &key,
filesystem_item &fsi) const -> api_error override; std::string &value) const
-> api_error override;
[[nodiscard]] auto get_filesystem_item_and_file( [[nodiscard]] auto get_pinned_files() const
const std::string &api_path, api_file &f, -> std::vector<std::string> override;
filesystem_item &fsi) const -> api_error override;
[[nodiscard]] auto get_filesystem_item_from_source_path(
const std::string &source_path,
filesystem_item &fsi) const -> api_error override;
[[nodiscard]] auto
get_item_meta(const std::string &api_path,
api_meta_map &meta) const -> api_error override;
[[nodiscard]] auto
get_item_meta(const std::string &api_path, const std::string &key,
std::string &value) const -> api_error override;
[[nodiscard]] auto
get_pinned_files() const -> std::vector<std::string> override;
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t override; [[nodiscard]] auto get_total_item_count() const -> std::uint64_t override;
[[nodiscard]] auto get_used_drive_space() const -> std::uint64_t override; [[nodiscard]] auto get_used_drive_space() const -> std::uint64_t override;
[[nodiscard]] auto [[nodiscard]] auto is_file_writeable(const std::string &api_path) const
is_file_writeable(const std::string &api_path) const -> bool override; -> bool override;
[[nodiscard]] auto is_read_only() const -> bool override { return false; } [[nodiscard]] auto is_read_only() const -> bool override { return false; }
[[nodiscard]] auto [[nodiscard]] auto remove_directory(const std::string &api_path)
remove_directory(const std::string &api_path) -> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto remove_file(const std::string &api_path)
remove_file(const std::string &api_path) -> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto remove_item_meta(const std::string &api_path,
remove_item_meta(const std::string &api_path, const std::string &key)
const std::string &key) -> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto set_item_meta(const std::string &api_path,
set_item_meta(const std::string &api_path, const std::string &key, const std::string &key,
const std::string &value) -> api_error override; const std::string &value)
-> api_error override;
[[nodiscard]] auto [[nodiscard]] auto set_item_meta(const std::string &api_path,
set_item_meta(const std::string &api_path, const api_meta_map &meta)
const api_meta_map &meta) -> api_error override; -> api_error override;
[[nodiscard]] auto start(api_item_added_callback api_item_added, [[nodiscard]] auto start(api_item_added_callback api_item_added,
i_file_manager *mgr) -> bool override; i_file_manager *mgr) -> bool override;
void stop() override; void stop() override;
[[nodiscard]] auto [[nodiscard]] auto upload_file(const std::string &api_path,
upload_file(const std::string &api_path, const std::string &source_path, const std::string &source_path,
stop_type &stop_requested) -> api_error override; stop_type &stop_requested)
-> api_error override;
}; };
} // namespace repertory } // namespace repertory

View File

@ -111,7 +111,8 @@ public:
[[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const [[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const
-> api_error override; -> api_error override;
[[nodiscard]] auto get_file_list(api_file_list &list) const [[nodiscard]] auto get_file_list(api_file_list &list,
std::string &marker) const
-> api_error override; -> api_error override;
[[nodiscard]] auto get_file_size(const std::string &api_path, [[nodiscard]] auto get_file_size(const std::string &api_path,

View File

@ -58,7 +58,8 @@ public:
[[nodiscard]] virtual auto get_file(const std::string &api_path, [[nodiscard]] virtual auto get_file(const std::string &api_path,
api_file &file) const -> api_error = 0; api_file &file) const -> api_error = 0;
[[nodiscard]] virtual auto get_file_list(api_file_list &list) const [[nodiscard]] virtual auto get_file_list(api_file_list &list,
std::string &marker) const
-> api_error = 0; -> api_error = 0;
[[nodiscard]] virtual auto get_file_size(const std::string &api_path, [[nodiscard]] virtual auto get_file_size(const std::string &api_path,

View File

@ -63,14 +63,16 @@ public:
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t; [[nodiscard]] auto get_total_item_count() const -> std::uint64_t;
[[nodiscard]] auto get_total_size() const -> std::uint64_t;
void remove_api_path(const std::string &api_path); void remove_api_path(const std::string &api_path);
[[nodiscard]] auto remove_item_meta(const std::string &api_path, [[nodiscard]] auto remove_item_meta(const std::string &api_path,
const std::string &key) -> api_error; const std::string &key) -> api_error;
[[nodiscard]] auto [[nodiscard]] auto rename_item_meta(const std::string &from_api_path,
rename_item_meta(const std::string &from_api_path, const std::string &to_api_path)
const std::string &to_api_path) -> api_error; -> api_error;
[[nodiscard]] auto set_item_meta(const std::string &api_path, [[nodiscard]] auto set_item_meta(const std::string &api_path,
const std::string &key, const std::string &key,

View File

@ -47,70 +47,70 @@ public:
auto operator=(s3_provider &&) -> s3_provider & = delete; auto operator=(s3_provider &&) -> s3_provider & = delete;
private: private:
[[nodiscard]] auto [[nodiscard]] auto add_if_not_found(api_file &file,
add_if_not_found(api_file &file, const std::string &object_name) const
const std::string &object_name) const -> api_error; -> api_error;
[[nodiscard]] auto [[nodiscard]] auto create_file_extra(const std::string &api_path,
create_file_extra(const std::string &api_path, api_meta_map &meta)
api_meta_map &meta) -> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto create_path_directories(const std::string &api_path,
create_path_directories(const std::string &api_path, const std::string &key) const
const std::string &key) const -> api_error; -> api_error;
[[nodiscard]] auto [[nodiscard]] auto decrypt_object_name(std::string &object_name) const
decrypt_object_name(std::string &object_name) const -> api_error; -> api_error;
[[nodiscard]] auto [[nodiscard]] auto get_last_modified(bool directory,
get_last_modified(bool directory, const std::string &api_path) const
const std::string &api_path) const -> std::uint64_t; -> std::uint64_t;
[[nodiscard]] auto [[nodiscard]] auto
get_object_info(bool directory, const std::string &api_path, get_object_info(bool directory, const std::string &api_path,
bool &is_encrypted, std::string &object_name, bool &is_encrypted, std::string &object_name,
head_object_result &result) const -> api_error; head_object_result &result) const -> api_error;
[[nodiscard]] auto get_object_list( [[nodiscard]] auto
std::string &response_data, long &response_code, get_object_list(std::string &response_data, long &response_code,
std::optional<std::string> delimiter = std::nullopt, std::optional<std::string> delimiter = std::nullopt,
std::optional<std::string> prefix = std::nullopt, std::optional<std::string> prefix = std::nullopt,
std::optional<std::string> token = std::nullopt) const -> bool; std::optional<std::string> token = std::nullopt) const
-> bool;
protected: protected:
[[nodiscard]] auto [[nodiscard]] auto create_directory_impl(const std::string &api_path,
create_directory_impl(const std::string &api_path, api_meta_map &meta)
api_meta_map &meta) -> api_error override; -> api_error override;
[[nodiscard]] auto get_directory_items_impl(const std::string &api_path, [[nodiscard]] auto get_directory_items_impl(const std::string &api_path,
directory_item_list &list) const directory_item_list &list) const
-> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto remove_directory_impl(const std::string &api_path)
get_used_drive_space_impl() const -> std::uint64_t override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto remove_file_impl(const std::string &api_path)
remove_directory_impl(const std::string &api_path) -> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto upload_file_impl(const std::string &api_path,
remove_file_impl(const std::string &api_path) -> api_error override; const std::string &source_path,
stop_type &stop_requested)
[[nodiscard]] auto -> api_error override;
upload_file_impl(const std::string &api_path, const std::string &source_path,
stop_type &stop_requested) -> api_error override;
public: public:
[[nodiscard]] static auto [[nodiscard]] static auto convert_api_date(std::string_view date)
convert_api_date(std::string_view date) -> std::uint64_t; -> std::uint64_t;
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const [[nodiscard]] auto get_directory_item_count(const std::string &api_path) const
-> std::uint64_t override; -> std::uint64_t override;
[[nodiscard]] auto get_file(const std::string &api_path, [[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const
api_file &file) const -> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto get_file_list(api_file_list &list,
get_file_list(api_file_list &list) const -> api_error override; std::string &marker) const
-> api_error override;
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override; [[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override;
@ -121,8 +121,8 @@ public:
[[nodiscard]] auto is_directory(const std::string &api_path, [[nodiscard]] auto is_directory(const std::string &api_path,
bool &exists) const -> api_error override; bool &exists) const -> api_error override;
[[nodiscard]] auto is_file(const std::string &api_path, [[nodiscard]] auto is_file(const std::string &api_path, bool &exists) const
bool &exists) const -> api_error override; -> api_error override;
[[nodiscard]] auto is_online() const -> bool override; [[nodiscard]] auto is_online() const -> bool override;
@ -130,14 +130,15 @@ public:
return false; return false;
}; };
[[nodiscard]] auto [[nodiscard]] auto read_file_bytes(const std::string &api_path,
read_file_bytes(const std::string &api_path, std::size_t size, std::size_t size, std::uint64_t offset,
std::uint64_t offset, data_buffer &data, data_buffer &data,
stop_type &stop_requested) -> api_error override; stop_type &stop_requested)
-> api_error override;
[[nodiscard]] auto [[nodiscard]] auto rename_file(const std::string &from_api_path,
rename_file(const std::string &from_api_path, const std::string &to_api_path)
const std::string &to_api_path) -> api_error override; -> api_error override;
[[nodiscard]] auto start(api_item_added_callback api_item_added, [[nodiscard]] auto start(api_item_added_callback api_item_added,
i_file_manager *mgr) -> bool override; i_file_manager *mgr) -> bool override;

View File

@ -61,9 +61,6 @@ protected:
directory_item_list &list) const directory_item_list &list) const
-> api_error override; -> api_error override;
[[nodiscard]] auto get_used_drive_space_impl() const
-> std::uint64_t override;
[[nodiscard]] auto remove_directory_impl(const std::string &api_path) [[nodiscard]] auto remove_directory_impl(const std::string &api_path)
-> api_error override; -> api_error override;
@ -82,7 +79,8 @@ public:
[[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const [[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const
-> api_error override; -> api_error override;
[[nodiscard]] auto get_file_list(api_file_list &list) const [[nodiscard]] auto get_file_list(api_file_list &list,
std::string &marker) const
-> api_error override; -> api_error override;
[[nodiscard]] auto get_provider_type() const -> provider_type override { [[nodiscard]] auto get_provider_type() const -> provider_type override {

View File

@ -79,6 +79,7 @@ enum class api_error {
invalid_version, invalid_version,
item_exists, item_exists,
item_not_found, item_not_found,
more_data,
no_disk_space, no_disk_space,
not_implemented, not_implemented,
not_supported, not_supported,
@ -95,16 +96,16 @@ enum class api_error {
[[nodiscard]] auto api_error_from_string(std::string_view str) -> api_error; [[nodiscard]] auto api_error_from_string(std::string_view str) -> api_error;
[[nodiscard]] auto [[nodiscard]] auto api_error_to_string(const api_error &error)
api_error_to_string(const api_error &error) -> const std::string &; -> const std::string &;
enum class download_type { direct, fallback, ring_buffer }; enum class download_type { direct, fallback, ring_buffer };
[[nodiscard]] auto [[nodiscard]] auto download_type_from_string(std::string type,
download_type_from_string(std::string type, const download_type &default_type)
const download_type &default_type) -> download_type; -> download_type;
[[nodiscard]] auto [[nodiscard]] auto download_type_to_string(const download_type &type)
download_type_to_string(const download_type &type) -> std::string; -> std::string;
enum class exit_code : std::int32_t { enum class exit_code : std::int32_t {
success, success,

View File

@ -38,18 +38,6 @@ auto eviction::check_minimum_requirements(const std::string &file_path)
auto check_file = utils::file::file{file_path}; auto check_file = utils::file::file{file_path};
auto opt_size = check_file.size();
if (not opt_size.has_value()) {
utils::error::raise_error(function_name, utils::get_last_error_code(),
file_path, "failed to get file size");
return false;
}
auto file_size{opt_size.value()};
if (file_size == 0U) {
return false;
}
auto reference_time = auto reference_time =
check_file.get_time(config_.get_eviction_uses_accessed_time() check_file.get_time(config_.get_eviction_uses_accessed_time()
? utils::file::time_type::accessed ? utils::file::time_type::accessed

View File

@ -81,8 +81,8 @@ auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid,
struct fuse_file_info * /*file_info*/) struct fuse_file_info * /*file_info*/)
-> api_error { -> api_error {
#else #else
auto fuse_drive::chown_impl(std::string api_path, uid_t uid, auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid)
gid_t gid) -> api_error { -> api_error {
#endif #endif
return check_and_perform( return check_and_perform(
api_path, X_OK, [&](api_meta_map &meta) -> api_error { api_path, X_OK, [&](api_meta_map &meta) -> api_error {
@ -481,8 +481,8 @@ auto fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st,
struct fuse_file_info * /*file_info*/) struct fuse_file_info * /*file_info*/)
-> api_error { -> api_error {
#else #else
auto fuse_drive::getattr_impl(std::string api_path, auto fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st)
struct stat *unix_st) -> api_error { -> api_error {
#endif #endif
auto parent = utils::path::get_parent_api_path(api_path); auto parent = utils::path::get_parent_api_path(api_path);
@ -565,8 +565,8 @@ auto fuse_drive::getxtimes_impl(std::string api_path, struct timespec *bkuptime,
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto fuse_drive::init_impl(struct fuse_conn_info *conn, auto fuse_drive::init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg)
struct fuse_config *cfg) -> void * { -> void * {
#else #else
void *fuse_drive::init_impl(struct fuse_conn_info *conn) { void *fuse_drive::init_impl(struct fuse_conn_info *conn) {
#endif #endif
@ -588,8 +588,6 @@ void *fuse_drive::init_impl(struct fuse_conn_info *conn) {
event_system::instance().start(); event_system::instance().start();
was_mounted_ = true; was_mounted_ = true;
polling::instance().start(&config_);
fm_ = std::make_unique<file_manager>(config_, provider_); fm_ = std::make_unique<file_manager>(config_, provider_);
server_ = std::make_unique<full_server>(config_, provider_, *fm_); server_ = std::make_unique<full_server>(config_, provider_, *fm_);
if (not provider_.is_read_only()) { if (not provider_.is_read_only()) {
@ -622,6 +620,9 @@ void *fuse_drive::init_impl(struct fuse_conn_info *conn) {
if (not lock_data_.set_mount_state(true, get_mount_location(), getpid())) { if (not lock_data_.set_mount_state(true, get_mount_location(), getpid())) {
utils::error::raise_error(function_name, "failed to set mount state"); utils::error::raise_error(function_name, "failed to set mount state");
} }
polling::instance().start(&config_);
event_system::instance().raise<drive_mounted>(get_mount_location()); event_system::instance().raise<drive_mounted>(get_mount_location());
} catch (const std::exception &e) { } catch (const std::exception &e) {
utils::error::raise_error(function_name, e, "exception during fuse init"); utils::error::raise_error(function_name, e, "exception during fuse init");
@ -799,8 +800,9 @@ auto fuse_drive::release_impl(std::string /*api_path*/,
return api_error::success; return api_error::success;
} }
auto fuse_drive::releasedir_impl( auto fuse_drive::releasedir_impl(std::string /*api_path*/,
std::string /*api_path*/, struct fuse_file_info *file_info) -> api_error { struct fuse_file_info *file_info)
-> api_error {
auto iter = directory_cache_->get_directory(file_info->fh); auto iter = directory_cache_->get_directory(file_info->fh);
if (iter == nullptr) { if (iter == nullptr) {
return api_error::invalid_handle; return api_error::invalid_handle;
@ -818,8 +820,8 @@ auto fuse_drive::rename_directory(const std::string &from_api_path,
} }
auto fuse_drive::rename_file(const std::string &from_api_path, auto fuse_drive::rename_file(const std::string &from_api_path,
const std::string &to_api_path, const std::string &to_api_path, bool overwrite)
bool overwrite) -> int { -> int {
auto res = fm_->rename_file(from_api_path, to_api_path, overwrite); auto res = fm_->rename_file(from_api_path, to_api_path, overwrite);
errno = std::abs(utils::from_api_error(res)); errno = std::abs(utils::from_api_error(res));
return (res == api_error::success) ? 0 : -1; return (res == api_error::success) ? 0 : -1;
@ -829,8 +831,8 @@ auto fuse_drive::rename_file(const std::string &from_api_path,
auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path, auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path,
unsigned int /*flags*/) -> api_error { unsigned int /*flags*/) -> api_error {
#else #else
auto fuse_drive::rename_impl(std::string from_api_path, auto fuse_drive::rename_impl(std::string from_api_path, std::string to_api_path)
std::string to_api_path) -> api_error { -> api_error {
#endif #endif
auto res = check_parent_access(to_api_path, W_OK | X_OK); auto res = check_parent_access(to_api_path, W_OK | X_OK);
if (res != api_error::success) { if (res != api_error::success) {
@ -944,15 +946,15 @@ auto fuse_drive::getxattr_impl(std::string api_path, const char *name,
} }
#else // __APPLE__ #else // __APPLE__
auto fuse_drive::getxattr_impl(std::string api_path, const char *name, auto fuse_drive::getxattr_impl(std::string api_path, const char *name,
char *value, size_t size, char *value, size_t size, int &attribute_size)
int &attribute_size) -> api_error { -> api_error {
return getxattr_common(api_path, name, value, size, attribute_size, nullptr); return getxattr_common(api_path, name, value, size, attribute_size, nullptr);
} }
#endif // __APPLE__ #endif // __APPLE__
auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size, auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
int &required_size, int &required_size, bool &return_size)
bool &return_size) -> api_error { -> api_error {
auto check_size = (size == 0); auto check_size = (size == 0);
auto res = check_parent_access(api_path, X_OK); auto res = check_parent_access(api_path, X_OK);
@ -992,8 +994,8 @@ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size,
return res; return res;
} }
auto fuse_drive::removexattr_impl(std::string api_path, auto fuse_drive::removexattr_impl(std::string api_path, const char *name)
const char *name) -> api_error { -> api_error {
std::string attribute_name; std::string attribute_name;
#if defined(__APPLE__) #if defined(__APPLE__)
auto res = parse_xattr_parameters(name, 0, attribute_name, api_path); auto res = parse_xattr_parameters(name, 0, attribute_name, api_path);
@ -1021,8 +1023,8 @@ auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
uint32_t position) -> api_error { uint32_t position) -> api_error {
#else // __APPLE__ #else // __APPLE__
auto fuse_drive::setxattr_impl(std::string api_path, const char *name, auto fuse_drive::setxattr_impl(std::string api_path, const char *name,
const char *value, size_t size, const char *value, size_t size, int flags)
int flags) -> api_error { -> api_error {
#endif #endif
std::string attribute_name; std::string attribute_name;
#if defined(__APPLE__) #if defined(__APPLE__)
@ -1100,8 +1102,8 @@ void fuse_drive::set_item_meta(const std::string &api_path,
} }
#if defined(__APPLE__) #if defined(__APPLE__)
auto fuse_drive::setattr_x_impl(std::string api_path, auto fuse_drive::setattr_x_impl(std::string api_path, struct setattr_x *attr)
struct setattr_x *attr) -> api_error { -> api_error {
bool exists{}; bool exists{};
auto res = provider_.is_file(api_path, exists); auto res = provider_.is_file(api_path, exists);
if (res != api_error::success) { if (res != api_error::success) {
@ -1200,8 +1202,9 @@ auto fuse_drive::setattr_x_impl(std::string api_path,
return api_error::success; return api_error::success;
} }
auto fuse_drive::setbkuptime_impl( auto fuse_drive::setbkuptime_impl(std::string api_path,
std::string api_path, const struct timespec *bkuptime) -> api_error { const struct timespec *bkuptime)
-> api_error {
return check_and_perform( return check_and_perform(
api_path, X_OK, [&](api_meta_map &meta) -> api_error { api_path, X_OK, [&](api_meta_map &meta) -> api_error {
auto nanos = bkuptime->tv_nsec + auto nanos = bkuptime->tv_nsec +
@ -1237,8 +1240,8 @@ auto fuse_drive::setvolname_impl(const char * /*volname*/) -> api_error {
return api_error::success; return api_error::success;
} }
auto fuse_drive::statfs_x_impl(std::string /*api_path*/, auto fuse_drive::statfs_x_impl(std::string /*api_path*/, struct statfs *stbuf)
struct statfs *stbuf) -> api_error { -> api_error {
if (statfs(&config_.get_cache_directory()[0], stbuf) != 0) { if (statfs(&config_.get_cache_directory()[0], stbuf) != 0) {
return api_error::os_error; return api_error::os_error;
} }
@ -1263,8 +1266,8 @@ auto fuse_drive::statfs_x_impl(std::string /*api_path*/,
return api_error::success; return api_error::success;
} }
#else // __APPLE__ #else // __APPLE__
auto fuse_drive::statfs_impl(std::string /*api_path*/, auto fuse_drive::statfs_impl(std::string /*api_path*/, struct statvfs *stbuf)
struct statvfs *stbuf) -> api_error { -> api_error {
if (statvfs(config_.get_cache_directory().data(), stbuf) != 0) { if (statvfs(config_.get_cache_directory().data(), stbuf) != 0) {
return api_error::os_error; return api_error::os_error;
} }
@ -1344,8 +1347,8 @@ auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2],
struct fuse_file_info * /*file_info*/) struct fuse_file_info * /*file_info*/)
-> api_error { -> api_error {
#else #else
auto fuse_drive::utimens_impl(std::string api_path, auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2])
const struct timespec tv[2]) -> api_error { -> api_error {
#endif #endif
api_meta_map meta; api_meta_map meta;
auto res = provider_.get_item_meta(api_path, meta); auto res = provider_.get_item_meta(api_path, meta);

View File

@ -619,7 +619,6 @@ auto winfsp_drive::Mounted(PVOID host) -> NTSTATUS {
auto *file_system_host{ auto *file_system_host{
reinterpret_cast<FileSystemHost *>(host), reinterpret_cast<FileSystemHost *>(host),
}; };
polling::instance().start(&config_);
fm_ = std::make_unique<file_manager>(config_, provider_); fm_ = std::make_unique<file_manager>(config_, provider_);
server_ = std::make_unique<full_server>(config_, provider_, *fm_); server_ = std::make_unique<full_server>(config_, provider_, *fm_);
if (not provider_.is_read_only()) { if (not provider_.is_read_only()) {
@ -652,6 +651,7 @@ auto winfsp_drive::Mounted(PVOID host) -> NTSTATUS {
utils::error::raise_error(function_name, "failed to set mount state"); utils::error::raise_error(function_name, "failed to set mount state");
} }
polling::instance().start(&config_);
event_system::instance().raise<drive_mounted>(mount_location); event_system::instance().raise<drive_mounted>(mount_location);
} catch (const std::exception &e) { } catch (const std::exception &e) {
utils::error::raise_error(function_name, e, "exception occurred"); utils::error::raise_error(function_name, e, "exception occurred");

View File

@ -1096,18 +1096,4 @@ void file_manager::upload_handler() {
upload_notify_.notify_all(); upload_notify_.notify_all();
} }
} }
void file_manager::update_used_space(std::uint64_t &used_space) const {
recur_mutex_lock open_lock(open_file_mtx_);
for (auto &&item : open_file_lookup_) {
std::uint64_t file_size{};
auto res = provider_.get_file_size(item.second->get_api_path(), file_size);
if ((res == api_error::success) &&
(file_size != item.second->get_file_size()) &&
(used_space >= file_size)) {
used_space -= file_size;
used_space += item.second->get_file_size();
}
}
}
} // namespace repertory } // namespace repertory

View File

@ -33,8 +33,8 @@
namespace repertory { namespace repertory {
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 size, std::uint64_t file_time)
std::uint64_t file_time) -> api_file { -> 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);
@ -66,8 +66,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 &source_api_path, const std::string &api_path)
const std::string &api_path) -> api_error { -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
bool exists{}; bool exists{};
@ -164,8 +164,8 @@ auto base_provider::create_directory(const std::string &api_path,
return set_item_meta(api_path, meta); return set_item_meta(api_path, meta);
} }
auto base_provider::create_file(const std::string &api_path, auto base_provider::create_file(const std::string &api_path, api_meta_map &meta)
api_meta_map &meta) -> api_error { -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
bool exists{}; bool exists{};
@ -222,8 +222,9 @@ auto base_provider::create_file(const std::string &api_path,
return api_error::error; return api_error::error;
} }
auto base_provider::get_api_path_from_source( auto base_provider::get_api_path_from_source(const std::string &source_path,
const std::string &source_path, std::string &api_path) const -> api_error { std::string &api_path) const
-> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
if (source_path.empty()) { if (source_path.empty()) {
@ -236,8 +237,9 @@ auto base_provider::get_api_path_from_source(
return db3_->get_api_path(source_path, api_path); return db3_->get_api_path(source_path, api_path);
} }
auto base_provider::get_directory_items( auto base_provider::get_directory_items(const std::string &api_path,
const std::string &api_path, directory_item_list &list) const -> api_error { directory_item_list &list) const
-> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
bool exists{}; bool exists{};
@ -301,9 +303,10 @@ 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( auto base_provider::get_filesystem_item(const std::string &api_path,
const std::string &api_path, bool directory, bool directory,
filesystem_item &fsi) const -> api_error { filesystem_item &fsi) const
-> 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) {
@ -336,9 +339,10 @@ auto base_provider::get_filesystem_item(
return api_error::success; return api_error::success;
} }
auto base_provider::get_filesystem_item_and_file( auto base_provider::get_filesystem_item_and_file(const std::string &api_path,
const std::string &api_path, api_file &file, api_file &file,
filesystem_item &fsi) const -> api_error { filesystem_item &fsi) const
-> 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;
@ -399,11 +403,7 @@ auto base_provider::get_total_item_count() const -> std::uint64_t {
} }
auto base_provider::get_used_drive_space() const -> std::uint64_t { auto base_provider::get_used_drive_space() const -> std::uint64_t {
if (used_space == 0U) { return db3_->get_total_size();
update_used_drive_space();
}
return used_space;
} }
auto base_provider::is_file_writeable(const std::string &api_path) const auto base_provider::is_file_writeable(const std::string &api_path) const
@ -424,6 +424,10 @@ void base_provider::remove_deleted_files(bool source_only) {
auto source_list = auto source_list =
utils::file::directory{config_.get_cache_directory()}.get_files(); utils::file::directory{config_.get_cache_directory()}.get_files();
for (auto &&source_file : source_list) { for (auto &&source_file : source_list) {
if (stop_requested_) {
return;
}
filesystem_item fsi{}; filesystem_item fsi{};
if (get_filesystem_item_from_source_path(source_file->get_path(), fsi) != if (get_filesystem_item_from_source_path(source_file->get_path(), fsi) !=
api_error::item_not_found) { api_error::item_not_found) {
@ -466,16 +470,26 @@ void base_provider::remove_deleted_files(bool source_only) {
std::string source_path; std::string source_path;
}; };
{
api_file_list list{}; api_file_list list{};
auto res = get_file_list(list); std::string marker;
if (res != api_error::success) { auto res{api_error::more_data};
utils::error::raise_error(function_name, res, "failed to get file list"); while (not stop_requested_ && res == api_error::more_data) {
res = get_file_list(list, marker);
if (res != api_error::success && res != api_error::more_data) {
utils::error::raise_error(function_name, res,
"failed to get file list");
return; return;
} }
}
}
std::vector<removed_item> removed_list{}; std::vector<removed_item> removed_list{};
for (auto &&api_path : db3_->get_api_path_list()) { for (auto &&api_path : db3_->get_api_path_list()) {
if (stop_requested_) {
return;
}
api_meta_map meta{}; api_meta_map meta{};
if (get_item_meta(api_path, meta) != api_error::success) { if (get_item_meta(api_path, meta) != api_error::success) {
continue; continue;
@ -510,6 +524,10 @@ void base_provider::remove_deleted_files(bool source_only) {
utils::path::combine(config_.get_data_directory(), {"orphaned"}); utils::path::combine(config_.get_data_directory(), {"orphaned"});
for (auto &&item : removed_list) { for (auto &&item : removed_list) {
if (stop_requested_) {
return;
}
if (item.directory) { if (item.directory) {
continue; continue;
} }
@ -559,6 +577,10 @@ void base_provider::remove_deleted_files(bool source_only) {
} }
for (auto &&item : removed_list) { for (auto &&item : removed_list) {
if (stop_requested_) {
return;
}
if (not item.directory) { if (not item.directory) {
continue; continue;
} }
@ -664,6 +686,8 @@ auto base_provider::set_item_meta(const std::string &api_path,
auto base_provider::start(api_item_added_callback api_item_added, auto base_provider::start(api_item_added_callback api_item_added,
i_file_manager *mgr) -> bool { i_file_manager *mgr) -> bool {
stop_requested_ = false;
api_item_added_ = api_item_added; api_item_added_ = api_item_added;
fm_ = mgr; fm_ = mgr;
@ -702,30 +726,15 @@ auto base_provider::start(api_item_added_callback api_item_added,
polling::instance().set_callback({"check_deleted", polling::frequency::low, polling::instance().set_callback({"check_deleted", polling::frequency::low,
[this]() { remove_deleted_files(false); }}); [this]() { remove_deleted_files(false); }});
polling::instance().set_callback({"drive_space", polling::frequency::low,
[this]() { update_used_drive_space(); }});
return true; return true;
} }
void base_provider::stop() { void base_provider::stop() {
stop_requested_ = true;
polling::instance().remove_callback("check_deleted"); polling::instance().remove_callback("check_deleted");
polling::instance().remove_callback("drive_space");
db3_.reset(); db3_.reset();
} }
void base_provider::update_used_drive_space() const {
REPERTORY_USES_FUNCTION_NAME();
try {
auto next_used_space = get_used_drive_space_impl();
get_file_mgr()->update_used_space(next_used_space);
used_space = next_used_space;
} catch (const std::exception &ex) {
utils::error::raise_error(function_name, ex,
"failed to get used drive space");
}
}
auto base_provider::upload_file(const std::string &api_path, auto base_provider::upload_file(const std::string &api_path,
const std::string &source_path, const std::string &source_path,
stop_type &stop_requested) -> api_error { stop_type &stop_requested) -> api_error {

View File

@ -405,7 +405,9 @@ auto encrypt_provider::get_file(const std::string &api_path,
return api_error::error; return api_error::error;
} }
auto encrypt_provider::get_file_list(api_file_list &list) const -> api_error { auto encrypt_provider::get_file_list(api_file_list &list,
std::string & /* marker */) const
-> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto cfg = config_.get_encrypt_config(); const auto cfg = config_.get_encrypt_config();

View File

@ -44,13 +44,14 @@ meta_db::meta_db(const app_config &cfg) {
"data TEXT, " "data TEXT, "
"directory INTEGER, " "directory INTEGER, "
"pinned INTEGER, " "pinned INTEGER, "
"size INTEGER, "
"source_path TEXT" "source_path TEXT"
");"}, ");"},
}, },
}; };
db_ = utils::db::sqlite::create_db( db_ = utils::db::sqlite::create_db(
utils::path::combine(cfg.get_data_directory(), {"meta.db"}), utils::path::combine(cfg.get_data_directory(), {"provider_meta.db"}),
sql_create_tables); sql_create_tables);
} }
@ -90,8 +91,8 @@ auto meta_db::get_api_path_list() -> std::vector<std::string> {
return ret; return ret;
} }
auto meta_db::get_item_meta(const std::string &api_path, auto meta_db::get_item_meta(const std::string &api_path, api_meta_map &meta)
api_meta_map &meta) -> api_error { -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
auto result = utils::db::sqlite::db_select{*db_, table_name} auto result = utils::db::sqlite::db_select{*db_, table_name}
@ -114,9 +115,10 @@ auto meta_db::get_item_meta(const std::string &api_path,
row->get_column("directory").get_value<std::int64_t>() == 1); row->get_column("directory").get_value<std::int64_t>() == 1);
meta[META_PINNED] = utils::string::from_bool( meta[META_PINNED] = utils::string::from_bool(
row->get_column("pinned").get_value<std::int64_t>() == 1); row->get_column("pinned").get_value<std::int64_t>() == 1);
meta[META_SIZE] = std::to_string(static_cast<std::uint64_t>(
row->get_column("size").get_value<std::int64_t>()));
meta[META_SOURCE] = meta[META_SOURCE] =
row->get_column("source_path").get_value<std::string>(); row->get_column("source_path").get_value<std::string>();
return api_error::success; return api_error::success;
} }
@ -156,6 +158,9 @@ auto meta_db::get_item_meta(const std::string &api_path, const std::string &key,
: key == META_DIRECTORY : key == META_DIRECTORY
? utils::string::from_bool( ? utils::string::from_bool(
row->get_column("directory").get_value<std::int64_t>() == 1) row->get_column("directory").get_value<std::int64_t>() == 1)
: key == META_SIZE
? std::to_string(static_cast<std::uint64_t>(
row->get_column("size").get_value<std::int64_t>()))
: json::parse( : json::parse(
row->get_column("data").get_value<std::string>())[key] row->get_column("data").get_value<std::string>())[key]
.get<std::string>(); .get<std::string>();
@ -218,6 +223,28 @@ auto meta_db::get_total_item_count() const -> std::uint64_t {
return ret; return ret;
} }
auto meta_db::get_total_size() const -> std::uint64_t {
REPERTORY_USES_FUNCTION_NAME();
try {
auto result = utils::db::sqlite::db_select{*db_, table_name}
.column("SUM(size) as total_size")
.where("directory")
.equals(0)
.go();
std::optional<utils::db::sqlite::db_result::row> row;
if (result.get_row(row) && row.has_value()) {
return static_cast<std::uint64_t>(
row->get_column("total_size").get_value<std::int64_t>());
}
} catch (const std::exception &e) {
utils::error::raise_error(function_name, e, "failed to get total size");
}
return 0U;
}
void meta_db::remove_api_path(const std::string &api_path) { void meta_db::remove_api_path(const std::string &api_path) {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@ -274,16 +301,19 @@ auto meta_db::set_item_meta(const std::string &api_path,
return update_item_meta(api_path, existing_meta); return update_item_meta(api_path, existing_meta);
} }
auto meta_db::update_item_meta(const std::string &api_path, auto meta_db::update_item_meta(const std::string &api_path, api_meta_map meta)
api_meta_map meta) -> api_error { -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
auto directory = utils::string::to_bool(meta[META_DIRECTORY]); auto directory = utils::string::to_bool(meta[META_DIRECTORY]);
auto pinned = utils::string::to_bool(meta[META_PINNED]); auto pinned = utils::string::to_bool(meta[META_PINNED]);
auto size =
directory ? std::uint64_t(0U) : utils::string::to_uint64(meta[META_SIZE]);
auto source_path = meta[META_SOURCE]; auto source_path = meta[META_SOURCE];
meta.erase(META_DIRECTORY); meta.erase(META_DIRECTORY);
meta.erase(META_PINNED); meta.erase(META_PINNED);
meta.erase(META_SIZE);
meta.erase(META_SOURCE); meta.erase(META_SOURCE);
auto result = utils::db::sqlite::db_insert{*db_, table_name} auto result = utils::db::sqlite::db_insert{*db_, table_name}
@ -292,6 +322,7 @@ auto meta_db::update_item_meta(const std::string &api_path,
.column_value("data", nlohmann::json(meta).dump()) .column_value("data", nlohmann::json(meta).dump())
.column_value("directory", directory ? 1 : 0) .column_value("directory", directory ? 1 : 0)
.column_value("pinned", pinned ? 1 : 0) .column_value("pinned", pinned ? 1 : 0)
.column_value("size", static_cast<std::int64_t>(size))
.column_value("source_path", source_path) .column_value("source_path", source_path)
.go(); .go();
if (not result.ok()) { if (not result.ok()) {

View File

@ -43,8 +43,9 @@ s3_provider::s3_provider(app_config &config, i_http_comm &comm)
get_comm().enable_s3_path_style(config.get_s3_config().use_path_style); get_comm().enable_s3_path_style(config.get_s3_config().use_path_style);
} }
auto s3_provider::add_if_not_found( auto s3_provider::add_if_not_found(api_file &file,
api_file &file, const std::string &object_name) const -> api_error { const std::string &object_name) const
-> api_error {
api_meta_map meta{}; api_meta_map meta{};
if (get_item_meta(file.api_path, meta) == api_error::item_not_found) { if (get_item_meta(file.api_path, meta) == api_error::item_not_found) {
auto err = create_path_directories( auto err = create_path_directories(
@ -85,8 +86,8 @@ auto s3_provider::create_directory_impl(const std::string &api_path,
api_meta_map &meta) -> api_error { api_meta_map &meta) -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
stop_type stop_requested{false}; stop_type stop_requested{false};
if (is_encrypted) { if (is_encrypted) {
@ -109,7 +110,7 @@ auto s3_provider::create_directory_impl(const std::string &api_path,
{utils::collection::to_hex_string(result)})); {utils::collection::to_hex_string(result)}));
} }
const auto object_name = auto object_name =
utils::path::create_api_path(is_encrypted ? meta[META_KEY] : api_path); utils::path::create_api_path(is_encrypted ? meta[META_KEY] : api_path);
curl::requests::http_put_file put_file{}; curl::requests::http_put_file put_file{};
@ -161,17 +162,18 @@ auto s3_provider::create_file_extra(const std::string &api_path,
return api_error::success; return api_error::success;
} }
auto s3_provider::create_path_directories( auto s3_provider::create_path_directories(const std::string &api_path,
const std::string &api_path, const std::string &key) const -> api_error { const std::string &key) const
-> api_error {
if (api_path == "/") { if (api_path == "/") {
return api_error::success; return api_error::success;
} }
const auto encryption_token = get_config().get_s3_config().encryption_token; auto encryption_token = get_config().get_s3_config().encryption_token;
const auto is_encrypted = not encryption_token.empty(); auto is_encrypted = not encryption_token.empty();
const auto path_parts = utils::string::split(api_path, '/', false); auto path_parts = utils::string::split(api_path, '/', false);
const auto key_parts = utils::string::split(key, '/', false); auto key_parts = utils::string::split(key, '/', false);
if (is_encrypted && key_parts.size() != path_parts.size()) { if (is_encrypted && key_parts.size() != path_parts.size()) {
return api_error::error; return api_error::error;
@ -223,8 +225,8 @@ auto s3_provider::get_directory_item_count(const std::string &api_path) const
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
try { try {
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
if (is_encrypted) { if (is_encrypted) {
auto res = get_item_meta(api_path, META_KEY, key); auto res = get_item_meta(api_path, META_KEY, key);
@ -233,7 +235,7 @@ auto s3_provider::get_directory_item_count(const std::string &api_path) const
} }
} }
const auto object_name = auto object_name =
api_path == "/" api_path == "/"
? "" ? ""
: utils::path::create_api_path(is_encrypted ? key : api_path); : utils::path::create_api_path(is_encrypted ? key : api_path);
@ -295,12 +297,13 @@ auto s3_provider::get_directory_item_count(const std::string &api_path) const
return 0U; return 0U;
} }
auto s3_provider::get_directory_items_impl( auto s3_provider::get_directory_items_impl(const std::string &api_path,
const std::string &api_path, directory_item_list &list) const -> api_error { directory_item_list &list) const
-> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
auto ret = api_error::success; auto ret = api_error::success;
std::string key; std::string key;
@ -311,7 +314,7 @@ auto s3_provider::get_directory_items_impl(
} }
} }
const auto object_name = auto object_name =
api_path == "/" api_path == "/"
? "" ? ""
: utils::path::create_api_path(is_encrypted ? key : api_path); : utils::path::create_api_path(is_encrypted ? key : api_path);
@ -414,26 +417,35 @@ auto s3_provider::get_directory_items_impl(
for (auto &&node : node_list) { for (auto &&node : node_list) {
auto child_object_name = utils::path::create_api_path( auto child_object_name = utils::path::create_api_path(
node.node().select_node("Key").node().text().as_string()); node.node().select_node("Key").node().text().as_string());
if (child_object_name != utils::path::create_api_path(prefix)) { if (child_object_name == utils::path::create_api_path(prefix)) {
continue;
}
auto size = node.node().select_node("Size").node().text().as_ullong(); auto size = node.node().select_node("Size").node().text().as_ullong();
auto last_modified = convert_api_date( auto last_modified = convert_api_date(
node.node().select_node("LastModified").node().text().as_string()); node.node().select_node("LastModified").node().text().as_string());
add_directory_item( add_directory_item(false, child_object_name, last_modified,
false, child_object_name, last_modified, [this, &is_encrypted, &size](
[&is_encrypted, &size](const directory_item &) -> std::uint64_t { const directory_item &dir_item) -> std::uint64_t {
return is_encrypted ? utils::encryption::encrypting_reader:: std::string size_str;
if (get_item_meta(dir_item.api_path, META_SIZE,
size_str) == api_error::success) {
return utils::string::to_uint64(size_str);
}
return is_encrypted
? utils::encryption::encrypting_reader::
calculate_decrypted_size(size) calculate_decrypted_size(size)
: size; : size;
}); });
} }
} }
}
return ret; return ret;
} }
auto s3_provider::get_file(const std::string &api_path, auto s3_provider::get_file(const std::string &api_path, api_file &file) const
api_file &file) const -> api_error { -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
try { try {
@ -450,12 +462,20 @@ auto s3_provider::get_file(const std::string &api_path,
file.api_parent = utils::path::get_parent_api_path(api_path); file.api_parent = utils::path::get_parent_api_path(api_path);
file.accessed_date = file.changed_date = file.creation_date = file.accessed_date = file.changed_date = file.creation_date =
file.modified_date = result.last_modified; file.modified_date = result.last_modified;
file.key = is_encrypted ? utils::path::create_api_path(api_path) : "";
std::string size_str;
if (get_item_meta(file.api_path, META_SIZE, size_str) ==
api_error::success) {
file.file_size = utils::string::to_uint64(size_str);
} else {
file.file_size = file.file_size =
is_encrypted is_encrypted
? utils::encryption::encrypting_reader::calculate_decrypted_size( ? utils::encryption::encrypting_reader::calculate_decrypted_size(
result.content_length) result.content_length)
: result.content_length; : result.content_length;
file.key = is_encrypted ? utils::path::create_api_path(api_path) : ""; }
return add_if_not_found(file, object_name); return add_if_not_found(file, object_name);
} catch (const std::exception &e) { } catch (const std::exception &e) {
utils::error::raise_error(function_name, e, "exception occurred"); utils::error::raise_error(function_name, e, "exception occurred");
@ -464,18 +484,17 @@ auto s3_provider::get_file(const std::string &api_path,
return api_error::error; return api_error::error;
} }
auto s3_provider::get_file_list(api_file_list &list) const -> api_error { auto s3_provider::get_file_list(api_file_list &list, std::string &marker) const
-> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
auto grab_more{true};
std::string token{};
while (grab_more) {
std::string response_data; std::string response_data;
long response_code{}; long response_code{};
if (not get_object_list(response_data, response_code, std::nullopt, if (not get_object_list(response_data, response_code, std::nullopt,
std::nullopt, token)) { std::nullopt, marker)) {
return api_error::comm_error; return api_error::comm_error;
} }
marker.clear();
if (response_code != http_error_codes::ok) { if (response_code != http_error_codes::ok) {
utils::error::raise_error(function_name, response_code, utils::error::raise_error(function_name, response_code,
@ -491,12 +510,10 @@ auto s3_provider::get_file_list(api_file_list &list) const -> api_error {
return api_error::comm_error; return api_error::comm_error;
} }
grab_more = doc.select_node("/ListBucketResult/IsTruncated") auto grab_more =
.node() doc.select_node("/ListBucketResult/IsTruncated").node().text().as_bool();
.text()
.as_bool();
if (grab_more) { if (grab_more) {
token = doc.select_node("/ListBucketResult/NextContinuationToken") marker = doc.select_node("/ListBucketResult/NextContinuationToken")
.node() .node()
.text() .text()
.as_string(); .as_string();
@ -506,7 +523,10 @@ auto s3_provider::get_file_list(api_file_list &list) const -> api_error {
for (auto &&node : node_list) { for (auto &&node : node_list) {
auto api_path = auto api_path =
std::string{node.node().select_node("Key").node().text().as_string()}; std::string{node.node().select_node("Key").node().text().as_string()};
if (not utils::string::ends_with(api_path, "/")) { if (utils::string::ends_with(api_path, "/")) {
continue;
}
auto is_encrypted = auto is_encrypted =
not get_config().get_s3_config().encryption_token.empty(); not get_config().get_s3_config().encryption_token.empty();
if (is_encrypted) { if (is_encrypted) {
@ -522,14 +542,12 @@ auto s3_provider::get_file_list(api_file_list &list) const -> api_error {
file.api_path = utils::path::create_api_path(api_path); file.api_path = utils::path::create_api_path(api_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);
file.accessed_date = file.changed_date = file.creation_date = file.accessed_date = file.changed_date = file.creation_date =
file.modified_date = file.modified_date = convert_api_date(
convert_api_date(node.node() node.node().select_node("LastModified").node().text().as_string());
.select_node("LastModified") file.file_size =
.node() is_encrypted
.text() ? utils::encryption::encrypting_reader::calculate_decrypted_size(
.as_string()); size)
file.file_size = is_encrypted ? utils::encryption::encrypting_reader::
calculate_decrypted_size(size)
: size; : size;
file.key = is_encrypted ? utils::path::create_api_path(api_path) : ""; file.key = is_encrypted ? utils::path::create_api_path(api_path) : "";
auto err = add_if_not_found(file, api_path); auto err = add_if_not_found(file, api_path);
@ -539,14 +557,13 @@ auto s3_provider::get_file_list(api_file_list &list) const -> api_error {
list.push_back(std::move(file)); list.push_back(std::move(file));
} }
}
return grab_more ? api_error::more_data : api_error::success;
} }
return api_error::success; auto s3_provider::get_last_modified(bool directory,
} const std::string &api_path) const
-> std::uint64_t {
auto s3_provider::get_last_modified(
bool directory, const std::string &api_path) const -> std::uint64_t {
bool is_encrypted{}; bool is_encrypted{};
std::string object_name; std::string object_name;
head_object_result result{}; head_object_result result{};
@ -556,13 +573,14 @@ auto s3_provider::get_last_modified(
: utils::time::get_time_now(); : utils::time::get_time_now();
} }
auto s3_provider::get_object_info( auto s3_provider::get_object_info(bool directory, const std::string &api_path,
bool directory, const std::string &api_path, bool &is_encrypted, bool &is_encrypted, std::string &object_name,
std::string &object_name, head_object_result &result) const -> api_error { head_object_result &result) const
-> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
try { try {
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
is_encrypted = not cfg.encryption_token.empty(); is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
@ -607,10 +625,12 @@ auto s3_provider::get_object_info(
return api_error::error; return api_error::error;
} }
auto s3_provider::get_object_list( auto s3_provider::get_object_list(std::string &response_data,
std::string &response_data, long &response_code, long &response_code,
std::optional<std::string> delimiter, std::optional<std::string> prefix, std::optional<std::string> delimiter,
std::optional<std::string> token) const -> bool { std::optional<std::string> prefix,
std::optional<std::string> token) const
-> bool {
curl::requests::http_get get{}; curl::requests::http_get get{};
get.allow_timeout = true; get.allow_timeout = true;
get.aws_service = "aws:amz:" + get_config().get_s3_config().region + ":s3"; get.aws_service = "aws:amz:" + get_config().get_s3_config().region + ":s3";
@ -639,58 +659,8 @@ auto s3_provider::get_total_drive_space() const -> std::uint64_t {
return std::numeric_limits<std::int64_t>::max() / std::int64_t(2); return std::numeric_limits<std::int64_t>::max() / std::int64_t(2);
} }
auto s3_provider::get_used_drive_space_impl() const -> std::uint64_t { auto s3_provider::is_directory(const std::string &api_path, bool &exists) const
auto grab_more{true}; -> api_error {
std::string token{};
std::uint64_t total_size{};
while (grab_more) {
std::string response_data;
long response_code{};
if (not get_object_list(response_data, response_code, std::nullopt,
std::nullopt, token)) {
return total_size;
}
if (response_code != http_error_codes::ok) {
return total_size;
}
pugi::xml_document doc;
auto res = doc.load_string(response_data.c_str());
if (res.status != pugi::xml_parse_status::status_ok) {
return total_size;
}
grab_more = doc.select_node("/ListBucketResult/IsTruncated")
.node()
.text()
.as_bool();
if (grab_more) {
token = doc.select_node("/ListBucketResult/NextContinuationToken")
.node()
.text()
.as_string();
}
const auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty();
auto node_list = doc.select_nodes("/ListBucketResult/Contents");
total_size = std::accumulate(
node_list.begin(), node_list.end(), total_size,
[&is_encrypted](std::uint64_t total, auto node) -> std::uint64_t {
auto size = node.node().select_node("Size").node().text().as_ullong();
return total + (is_encrypted ? utils::encryption::encrypting_reader::
calculate_decrypted_size(size)
: size);
});
}
return total_size;
}
auto s3_provider::is_directory(const std::string &api_path,
bool &exists) const -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
exists = false; exists = false;
@ -717,8 +687,8 @@ auto s3_provider::is_directory(const std::string &api_path,
return api_error::error; return api_error::error;
} }
auto s3_provider::is_file(const std::string &api_path, auto s3_provider::is_file(const std::string &api_path, bool &exists) const
bool &exists) const -> api_error { -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
exists = false; exists = false;
@ -755,8 +725,8 @@ auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size,
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
try { try {
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
if (is_encrypted) { if (is_encrypted) {
auto res = get_item_meta(api_path, META_KEY, key); auto res = get_item_meta(api_path, META_KEY, key);
@ -765,7 +735,7 @@ auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size,
} }
} }
const auto object_name = auto object_name =
utils::path::create_api_path(is_encrypted ? key : api_path); utils::path::create_api_path(is_encrypted ? key : api_path);
const auto read_bytes = const auto read_bytes =
@ -825,14 +795,17 @@ auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size,
return res; return res;
}; };
if (is_encrypted) { if (not is_encrypted) {
return read_bytes(size, offset, data);
}
std::string temp; std::string temp;
auto res = get_item_meta(api_path, META_SIZE, temp); auto res = get_item_meta(api_path, META_SIZE, temp);
if (res != api_error::success) { if (res != api_error::success) {
return res; return res;
} }
const auto total_size = utils::string::to_uint64(temp);
auto total_size = utils::string::to_uint64(temp);
return utils::encryption::read_encrypted_range( return utils::encryption::read_encrypted_range(
{offset, offset + size - 1U}, {offset, offset + size - 1U},
utils::encryption::generate_key<utils::encryption::hash_256_t>( utils::encryption::generate_key<utils::encryption::hash_256_t>(
@ -846,9 +819,7 @@ auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size,
total_size, data) total_size, data)
? api_error::success ? api_error::success
: api_error::decryption_error; : api_error::decryption_error;
}
return read_bytes(size, offset, data);
} catch (const std::exception &e) { } catch (const std::exception &e) {
utils::error::raise_error(function_name, e, "exception occurred"); utils::error::raise_error(function_name, e, "exception occurred");
} }
@ -860,8 +831,8 @@ auto s3_provider::remove_directory_impl(const std::string &api_path)
-> api_error { -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
if (is_encrypted) { if (is_encrypted) {
@ -871,7 +842,7 @@ auto s3_provider::remove_directory_impl(const std::string &api_path)
} }
} }
const auto object_name = auto object_name =
utils::path::create_api_path(is_encrypted ? key : api_path); utils::path::create_api_path(is_encrypted ? key : api_path);
curl::requests::http_delete del{}; curl::requests::http_delete del{};
@ -902,8 +873,8 @@ auto s3_provider::remove_directory_impl(const std::string &api_path)
auto s3_provider::remove_file_impl(const std::string &api_path) -> api_error { auto s3_provider::remove_file_impl(const std::string &api_path) -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
if (is_encrypted) { if (is_encrypted) {
@ -913,7 +884,7 @@ auto s3_provider::remove_file_impl(const std::string &api_path) -> api_error {
} }
} }
const auto object_name = auto object_name =
utils::path::create_api_path(is_encrypted ? key : api_path); utils::path::create_api_path(is_encrypted ? key : api_path);
curl::requests::http_delete del{}; curl::requests::http_delete del{};
@ -973,8 +944,8 @@ auto s3_provider::upload_file_impl(const std::string &api_path,
file_size = opt_size.value(); file_size = opt_size.value();
} }
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
if (is_encrypted) { if (is_encrypted) {
@ -984,7 +955,7 @@ auto s3_provider::upload_file_impl(const std::string &api_path,
} }
} }
const auto object_name = auto object_name =
utils::path::create_api_path(is_encrypted ? key : api_path); utils::path::create_api_path(is_encrypted ? key : api_path);
curl::requests::http_put_file put_file{}; curl::requests::http_put_file put_file{};

View File

@ -214,7 +214,9 @@ auto sia_provider::get_file(const std::string &api_path, api_file &file) const
return api_error::success; return api_error::success;
} }
auto sia_provider::get_file_list(api_file_list &list) const -> api_error { auto sia_provider::get_file_list(api_file_list &list,
std::string & /* marker */) const
-> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
using dir_func = std::function<api_error(std::string api_path)>; using dir_func = std::function<api_error(std::string api_path)>;
@ -393,37 +395,6 @@ auto sia_provider::get_total_drive_space() const -> std::uint64_t {
return 0U; return 0U;
} }
auto sia_provider::get_used_drive_space_impl() const -> std::uint64_t {
REPERTORY_USES_FUNCTION_NAME();
curl::requests::http_get get{};
get.allow_timeout = true;
get.path = "/api/bus/stats/objects";
get.query["bucket"] = get_bucket(get_config().get_sia_config());
json object_data{};
get.response_handler = [&object_data](const data_buffer &data,
long response_code) {
if (response_code == http_error_codes::ok) {
object_data = nlohmann::json::parse(data.begin(), data.end());
}
};
long response_code{};
stop_type stop_requested{};
if (not get_comm().make_request(get, response_code, stop_requested)) {
return 0U;
}
if (response_code != http_error_codes::ok) {
utils::error::raise_error(function_name, response_code,
"failed to get used drive space");
return 0U;
}
return object_data["totalObjectsSize"].get<std::uint64_t>();
}
auto sia_provider::is_directory(const std::string &api_path, bool &exists) const auto sia_provider::is_directory(const std::string &api_path, bool &exists) const
-> api_error { -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();

View File

@ -25,8 +25,9 @@
#include "utils/string.hpp" #include "utils/string.hpp"
namespace repertory { namespace repertory {
auto download_type_from_string( auto download_type_from_string(std::string type,
std::string type, const download_type &default_type) -> download_type { const download_type &default_type)
-> download_type {
type = utils::string::to_lower(utils::string::trim(type)); type = utils::string::to_lower(utils::string::trim(type));
if (type == "direct") { if (type == "direct") {
return download_type::direct; return download_type::direct;
@ -84,6 +85,7 @@ static const std::unordered_map<api_error, std::string> LOOKUP = {
{api_error::invalid_version, "invalid_version"}, {api_error::invalid_version, "invalid_version"},
{api_error::item_exists, "item_exists"}, {api_error::item_exists, "item_exists"},
{api_error::item_not_found, "item_not_found"}, {api_error::item_not_found, "item_not_found"},
{api_error::more_data, "more_data"},
{api_error::no_disk_space, "no_disk_space"}, {api_error::no_disk_space, "no_disk_space"},
{api_error::not_implemented, "not_implemented"}, {api_error::not_implemented, "not_implemented"},
{api_error::not_supported, "not_supported"}, {api_error::not_supported, "not_supported"},

View File

@ -31,17 +31,13 @@ void polling::frequency_thread(
while (not stop_requested_) { while (not stop_requested_) {
std::deque<std::future<void>> futures; std::deque<std::future<void>> futures;
unique_mutex_lock lock(mutex_); unique_mutex_lock lock(mutex_);
if (not stop_requested_ &&
notify_.wait_for(lock, std::chrono::seconds(get_frequency_seconds())) ==
std::cv_status::timeout) {
for (const auto &item : items_) { for (const auto &item : items_) {
if (item.second.freq == freq) { if (item.second.freq == freq) {
futures.emplace_back( futures.emplace_back(
std::async(std::launch::async, [this, &freq, item]() -> void { std::async(std::launch::async, [this, &freq, item]() -> void {
if (config_->get_event_level() == event_level::trace || if (config_->get_event_level() == event_level::trace ||
freq != frequency::second) { freq != frequency::second) {
event_system::instance().raise<polling_item_begin>( event_system::instance().raise<polling_item_begin>(item.first);
item.first);
} }
item.second.action(); item.second.action();
if (config_->get_event_level() == event_level::trace || if (config_->get_event_level() == event_level::trace ||
@ -57,7 +53,13 @@ void polling::frequency_thread(
futures.front().wait(); futures.front().wait();
futures.pop_front(); futures.pop_front();
} }
lock.lock();
if (stop_requested_) {
continue;
} }
notify_.wait_for(lock, std::chrono::seconds(get_frequency_seconds()));
} }
} }
@ -73,7 +75,10 @@ void polling::set_callback(const polling_item &item) {
void polling::start(app_config *config) { void polling::start(app_config *config) {
mutex_lock lock(start_stop_mutex_); mutex_lock lock(start_stop_mutex_);
if (not high_frequency_thread_) { if (high_frequency_thread_) {
return;
}
event_system::instance().raise<service_started>("polling"); event_system::instance().raise<service_started>("polling");
config_ = config; config_ = config;
stop_requested_ = false; stop_requested_ = false;
@ -96,27 +101,27 @@ void polling::start(app_config *config) {
frequency::second); frequency::second);
}); });
} }
}
void polling::stop() { void polling::stop() {
if (high_frequency_thread_) {
event_system::instance().raise<service_shutdown_begin>("polling");
mutex_lock lock(start_stop_mutex_); mutex_lock lock(start_stop_mutex_);
if (high_frequency_thread_) { if (not high_frequency_thread_) {
{ return;
}
event_system::instance().raise<service_shutdown_begin>("polling");
stop_requested_ = true; stop_requested_ = true;
mutex_lock lock2(mutex_); unique_mutex_lock lock2(mutex_);
notify_.notify_all(); notify_.notify_all();
} lock2.unlock();
high_frequency_thread_->join(); high_frequency_thread_->join();
low_frequency_thread_->join(); low_frequency_thread_->join();
second_frequency_thread_->join(); second_frequency_thread_->join();
high_frequency_thread_.reset(); high_frequency_thread_.reset();
low_frequency_thread_.reset(); low_frequency_thread_.reset();
second_frequency_thread_.reset(); second_frequency_thread_.reset();
}
event_system::instance().raise<service_shutdown_end>("polling"); event_system::instance().raise<service_shutdown_end>("polling");
} }
}
} // namespace repertory } // namespace repertory

View File

@ -60,8 +60,8 @@ public:
MOCK_METHOD(api_error, get_file, MOCK_METHOD(api_error, get_file,
(const std::string &api_path, api_file &file), (const, override)); (const std::string &api_path, api_file &file), (const, override));
MOCK_METHOD(api_error, get_file_list, (api_file_list & list), MOCK_METHOD(api_error, get_file_list,
(const, override)); (api_file_list & list, std::string &marker), (const, override));
MOCK_METHOD(api_error, get_file_size, MOCK_METHOD(api_error, get_file_size,
(const std::string &api_path, std::uint64_t &file_size), (const std::string &api_path, std::uint64_t &file_size),

View File

@ -547,7 +547,8 @@ static void get_file_fails_if_item_is_directory(const app_config &cfg,
static void get_file_list(const app_config &cfg, i_provider &provider) { static void get_file_list(const app_config &cfg, i_provider &provider) {
api_file_list list{}; api_file_list list{};
EXPECT_EQ(api_error::success, provider.get_file_list(list)); std::string marker;
EXPECT_EQ(api_error::success, provider.get_file_list(list, marker));
if (provider.get_provider_type() == provider_type::encrypt) { if (provider.get_provider_type() == provider_type::encrypt) {
EXPECT_EQ(std::size_t(2U), list.size()); EXPECT_EQ(std::size_t(2U), list.size());