refactor
This commit is contained in:
@ -57,8 +57,8 @@ public:
|
||||
open_file_base(const open_file_base &) noexcept = delete;
|
||||
open_file_base(open_file_base &&) noexcept = delete;
|
||||
auto operator=(open_file_base &&) noexcept -> open_file_base & = delete;
|
||||
auto
|
||||
operator=(const open_file_base &) noexcept -> open_file_base & = delete;
|
||||
auto operator=(const open_file_base &) noexcept
|
||||
-> open_file_base & = delete;
|
||||
|
||||
public:
|
||||
class download final {
|
||||
@ -168,17 +168,17 @@ public:
|
||||
|
||||
[[nodiscard]] auto get_filesystem_item() const -> filesystem_item override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_handles() const -> std::vector<std::uint64_t> override;
|
||||
[[nodiscard]] auto get_handles() const
|
||||
-> std::vector<std::uint64_t> override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_open_data() -> std::map<std::uint64_t, open_file_data> & override;
|
||||
[[nodiscard]] auto get_open_data()
|
||||
-> std::map<std::uint64_t, open_file_data> & override;
|
||||
|
||||
[[nodiscard]] auto get_open_data() const
|
||||
-> const std::map<std::uint64_t, open_file_data> & override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_open_data(std::uint64_t handle) -> open_file_data & override;
|
||||
[[nodiscard]] auto get_open_data(std::uint64_t handle)
|
||||
-> open_file_data & override;
|
||||
|
||||
[[nodiscard]] auto get_open_data(std::uint64_t handle) const
|
||||
-> const open_file_data & override;
|
||||
@ -267,8 +267,8 @@ public:
|
||||
public:
|
||||
auto close() -> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_read_state() const -> boost::dynamic_bitset<> override;
|
||||
[[nodiscard]] auto get_read_state() const
|
||||
-> boost::dynamic_bitset<> override;
|
||||
|
||||
[[nodiscard]] auto get_read_state(std::size_t chunk) const -> bool override;
|
||||
|
||||
@ -276,20 +276,20 @@ public:
|
||||
|
||||
auto is_write_supported() const -> bool override { return true; }
|
||||
|
||||
[[nodiscard]] auto
|
||||
native_operation(native_operation_callback callback) -> api_error override;
|
||||
[[nodiscard]] auto native_operation(native_operation_callback callback)
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
native_operation(std::uint64_t new_file_size,
|
||||
native_operation_callback callback) -> api_error override;
|
||||
[[nodiscard]] auto native_operation(std::uint64_t new_file_size,
|
||||
native_operation_callback callback)
|
||||
-> api_error override;
|
||||
|
||||
void remove(std::uint64_t handle) override;
|
||||
|
||||
[[nodiscard]] auto read(std::size_t read_size, std::uint64_t read_offset,
|
||||
data_buffer &data) -> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
resize(std::uint64_t new_file_size) -> api_error override;
|
||||
[[nodiscard]] auto resize(std::uint64_t new_file_size)
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto write(std::uint64_t write_offset,
|
||||
const data_buffer &data,
|
||||
@ -356,8 +356,8 @@ public:
|
||||
return last_chunk_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_read_state() const -> boost::dynamic_bitset<> override;
|
||||
[[nodiscard]] auto get_read_state() const
|
||||
-> boost::dynamic_bitset<> override;
|
||||
|
||||
[[nodiscard]] auto get_read_state(std::size_t chunk) const -> bool override;
|
||||
|
||||
@ -369,12 +369,12 @@ public:
|
||||
|
||||
auto is_write_supported() const -> bool override { return false; }
|
||||
|
||||
[[nodiscard]] auto
|
||||
native_operation(native_operation_callback callback) -> api_error override;
|
||||
[[nodiscard]] auto native_operation(native_operation_callback callback)
|
||||
-> api_error override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
native_operation(std::uint64_t,
|
||||
native_operation_callback) -> api_error override {
|
||||
[[nodiscard]] auto native_operation(std::uint64_t,
|
||||
native_operation_callback)
|
||||
-> api_error override {
|
||||
return api_error::not_supported;
|
||||
}
|
||||
|
||||
@ -391,8 +391,8 @@ public:
|
||||
|
||||
void set_api_path(const std::string &api_path) override;
|
||||
|
||||
[[nodiscard]] auto write(std::uint64_t, const data_buffer &,
|
||||
std::size_t &) -> api_error override {
|
||||
[[nodiscard]] auto write(std::uint64_t, const data_buffer &, std::size_t &)
|
||||
-> api_error override {
|
||||
return api_error::not_supported;
|
||||
}
|
||||
};
|
||||
@ -458,8 +458,7 @@ private:
|
||||
i_provider &provider_;
|
||||
|
||||
private:
|
||||
utils::db::sqlite::db3_t db_;
|
||||
std::uint64_t next_handle_{0U};
|
||||
std::atomic<std::uint64_t> next_handle_{0U};
|
||||
mutable std::recursive_mutex open_file_mtx_;
|
||||
std::unordered_map<std::string, std::shared_ptr<i_closeable_open_file>>
|
||||
open_file_lookup_;
|
||||
@ -470,6 +469,8 @@ private:
|
||||
std::unique_ptr<std::thread> upload_thread_;
|
||||
|
||||
private:
|
||||
[[nodiscard]] auto create_db() const -> utils::db::sqlite::db3_t;
|
||||
|
||||
void close_timed_out_files();
|
||||
|
||||
auto get_open_file_by_handle(std::uint64_t handle) const
|
||||
@ -483,12 +484,22 @@ private:
|
||||
std::shared_ptr<i_closeable_open_file> closeable_file) -> api_error;
|
||||
|
||||
void queue_upload(const std::string &api_path, const std::string &source_path,
|
||||
bool no_lock);
|
||||
bool no_lock, sqlite3 *db);
|
||||
|
||||
void remove_upload(const std::string &api_path, bool no_lock);
|
||||
void remove_resume(const std::string &api_path,
|
||||
const std::string &source_path, sqlite3 *db);
|
||||
|
||||
void remove_upload(const std::string &api_path, bool no_lock, sqlite3 *db);
|
||||
|
||||
[[nodiscard]] auto rename_directory(const std::string &from_api_path,
|
||||
const std::string &to_api_path,
|
||||
sqlite3 *db) -> api_error;
|
||||
|
||||
[[nodiscard]] auto rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path, bool overwrite,
|
||||
sqlite3 *db) -> api_error;
|
||||
void swap_renamed_items(std::string from_api_path, std::string to_api_path,
|
||||
bool directory);
|
||||
bool directory, sqlite3 *db);
|
||||
|
||||
void upload_completed(const file_upload_completed &evt);
|
||||
|
||||
@ -498,7 +509,8 @@ public:
|
||||
[[nodiscard]] auto get_next_handle() -> std::uint64_t;
|
||||
|
||||
auto handle_file_rename(const std::string &from_api_path,
|
||||
const std::string &to_api_path) -> api_error;
|
||||
const std::string &to_api_path, sqlite3 *db)
|
||||
-> api_error;
|
||||
|
||||
void queue_upload(const i_open_file &file) override;
|
||||
|
||||
@ -537,8 +549,8 @@ public:
|
||||
|
||||
[[nodiscard]] auto has_no_open_file_handles() const -> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
is_processing(const std::string &api_path) const -> bool override;
|
||||
[[nodiscard]] auto is_processing(const std::string &api_path) const
|
||||
-> bool override;
|
||||
|
||||
#if defined(PROJECT_TESTING)
|
||||
[[nodiscard]] auto open(std::shared_ptr<i_closeable_open_file> of,
|
||||
@ -551,13 +563,13 @@ public:
|
||||
|
||||
[[nodiscard]] auto remove_file(const std::string &api_path) -> api_error;
|
||||
|
||||
[[nodiscard]] auto
|
||||
rename_directory(const std::string &from_api_path,
|
||||
const std::string &to_api_path) -> api_error;
|
||||
[[nodiscard]] auto rename_directory(const std::string &from_api_path,
|
||||
const std::string &to_api_path)
|
||||
-> api_error;
|
||||
|
||||
[[nodiscard]] auto rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path,
|
||||
bool overwrite) -> api_error;
|
||||
const std::string &to_api_path, bool overwrite)
|
||||
-> api_error;
|
||||
|
||||
void start();
|
||||
|
||||
|
Reference in New Issue
Block a user