refactor meta db to allow alternate implementations
This commit is contained in:
parent
62857e1372
commit
c8f2485ff0
76
repertory/librepertory/include/db/i_meta_db.hpp
Normal file
76
repertory/librepertory/include/db/i_meta_db.hpp
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
Copyright <2018-2024> <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_DB_I_META_DB_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_DB_I_META_DB_HPP_
|
||||||
|
|
||||||
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
class i_meta_db {
|
||||||
|
INTERFACE_SETUP(i_meta_db);
|
||||||
|
|
||||||
|
public:
|
||||||
|
[[nodiscard]] virtual auto get_api_path(const std::string &source_path,
|
||||||
|
std::string &api_path) const
|
||||||
|
-> api_error = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual auto get_api_path_list() const
|
||||||
|
-> std::vector<std::string> = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual auto get_item_meta(const std::string &api_path,
|
||||||
|
api_meta_map &meta) const
|
||||||
|
-> api_error = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual auto get_item_meta(const std::string &api_path,
|
||||||
|
const std::string &key,
|
||||||
|
std::string &value) const
|
||||||
|
-> api_error = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual auto get_pinned_files() const
|
||||||
|
-> std::vector<std::string> = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual auto get_total_item_count() const -> std::uint64_t = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual auto get_total_size() const -> std::uint64_t = 0;
|
||||||
|
|
||||||
|
virtual void remove_api_path(const std::string &api_path) = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual auto remove_item_meta(const std::string &api_path,
|
||||||
|
const std::string &key)
|
||||||
|
-> api_error = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual auto rename_item_meta(const std::string &from_api_path,
|
||||||
|
const std::string &to_api_path)
|
||||||
|
-> api_error = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual auto set_item_meta(const std::string &api_path,
|
||||||
|
const std::string &key,
|
||||||
|
const std::string &value)
|
||||||
|
-> api_error = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual auto set_item_meta(const std::string &api_path,
|
||||||
|
const api_meta_map &meta)
|
||||||
|
-> api_error = 0;
|
||||||
|
};
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_DB_I_META_DB_HPP_
|
35
repertory/librepertory/include/db/meta_db.hpp
Normal file
35
repertory/librepertory/include/db/meta_db.hpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
Copyright <2018-2024> <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_DB_META_DB_HPP_
|
||||||
|
#define REPERTORY_INCLUDE_DB_META_DB_HPP_
|
||||||
|
|
||||||
|
#include "db/i_meta_db.hpp"
|
||||||
|
#include "db/sqlite_meta_db.hpp"
|
||||||
|
|
||||||
|
namespace repertory {
|
||||||
|
[[nodiscard]] inline auto create_meta_db(const app_config &cfg)
|
||||||
|
-> std::unique_ptr<i_meta_db> {
|
||||||
|
return std::make_unique<sqlite_meta_db>(cfg);
|
||||||
|
}
|
||||||
|
} // namespace repertory
|
||||||
|
|
||||||
|
#endif // REPERTORY_INCLUDE_DB_META_DB_HPP_
|
@ -19,24 +19,25 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#ifndef REPERTORY_INCLUDE_PROVIDERS_META_DB_HPP_
|
#ifndef REPERTORY_INCLUDE_DB_SQLITE_META_DB_HPP_
|
||||||
#define REPERTORY_INCLUDE_PROVIDERS_META_DB_HPP_
|
#define REPERTORY_INCLUDE_DB_SQLITE_META_DB_HPP_
|
||||||
|
|
||||||
|
#include "db/i_meta_db.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "utils/db/sqlite/db_common.hpp"
|
#include "utils/db/sqlite/db_common.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
class app_config;
|
class app_config;
|
||||||
|
|
||||||
class meta_db final {
|
class sqlite_meta_db final : public i_meta_db {
|
||||||
public:
|
public:
|
||||||
meta_db(const app_config &cfg);
|
sqlite_meta_db(const app_config &cfg);
|
||||||
~meta_db();
|
~sqlite_meta_db() override;
|
||||||
|
|
||||||
meta_db(const meta_db &) = delete;
|
sqlite_meta_db(const sqlite_meta_db &) = delete;
|
||||||
meta_db(meta_db &&) = delete;
|
sqlite_meta_db(sqlite_meta_db &&) = delete;
|
||||||
auto operator=(const meta_db &) -> meta_db & = delete;
|
auto operator=(const sqlite_meta_db &) -> sqlite_meta_db & = delete;
|
||||||
auto operator=(meta_db &&) -> meta_db & = delete;
|
auto operator=(sqlite_meta_db &&) -> sqlite_meta_db & = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
utils::db::sqlite::db3_t db_;
|
utils::db::sqlite::db3_t db_;
|
||||||
@ -48,39 +49,47 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] auto get_api_path(const std::string &source_path,
|
[[nodiscard]] auto get_api_path(const std::string &source_path,
|
||||||
std::string &api_path) -> api_error;
|
std::string &api_path) const
|
||||||
|
-> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_api_path_list() -> std::vector<std::string>;
|
[[nodiscard]] auto get_api_path_list() const
|
||||||
|
-> std::vector<std::string> override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_item_meta(const std::string &api_path,
|
[[nodiscard]] auto get_item_meta(const std::string &api_path,
|
||||||
api_meta_map &meta) -> api_error;
|
api_meta_map &meta) const
|
||||||
|
-> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_item_meta(const std::string &api_path,
|
[[nodiscard]] auto get_item_meta(const std::string &api_path,
|
||||||
const std::string &key,
|
const std::string &key,
|
||||||
std::string &value) const -> api_error;
|
std::string &value) const
|
||||||
|
-> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_pinned_files() const -> std::vector<std::string>;
|
[[nodiscard]] auto get_pinned_files() const
|
||||||
|
-> std::vector<std::string> override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t;
|
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t override;
|
||||||
|
|
||||||
[[nodiscard]] auto get_total_size() const -> std::uint64_t;
|
[[nodiscard]] auto get_total_size() const -> std::uint64_t override;
|
||||||
|
|
||||||
void remove_api_path(const std::string &api_path);
|
void remove_api_path(const std::string &api_path) override;
|
||||||
|
|
||||||
[[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 override;
|
||||||
|
|
||||||
[[nodiscard]] auto rename_item_meta(const std::string &from_api_path,
|
[[nodiscard]] auto 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 override;
|
||||||
|
|
||||||
[[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,
|
||||||
const std::string &value) -> api_error;
|
const std::string &value)
|
||||||
|
-> api_error override;
|
||||||
|
|
||||||
[[nodiscard]] auto set_item_meta(const std::string &api_path,
|
[[nodiscard]] auto set_item_meta(const std::string &api_path,
|
||||||
const api_meta_map &meta) -> api_error;
|
const api_meta_map &meta)
|
||||||
|
-> api_error override;
|
||||||
};
|
};
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
|
||||||
#endif // REPERTORY_INCLUDE_PROVIDERS_META_DB_HPP_
|
#endif // REPERTORY_INCLUDE_DB_SQLITE_META_DB_HPP_
|
@ -22,8 +22,8 @@
|
|||||||
#ifndef REPERTORY_INCLUDE_PROVIDERS_BASE_PROVIDER_HPP_
|
#ifndef REPERTORY_INCLUDE_PROVIDERS_BASE_PROVIDER_HPP_
|
||||||
#define REPERTORY_INCLUDE_PROVIDERS_BASE_PROVIDER_HPP_
|
#define REPERTORY_INCLUDE_PROVIDERS_BASE_PROVIDER_HPP_
|
||||||
|
|
||||||
|
#include "db/i_meta_db.hpp"
|
||||||
#include "providers/i_provider.hpp"
|
#include "providers/i_provider.hpp"
|
||||||
#include "providers/meta_db.hpp"
|
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
@ -49,7 +49,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
api_item_added_callback api_item_added_;
|
api_item_added_callback api_item_added_;
|
||||||
std::unique_ptr<meta_db> db3_;
|
std::unique_ptr<i_meta_db> db3_;
|
||||||
i_file_manager *fm_{};
|
i_file_manager *fm_{};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -106,9 +106,9 @@ protected:
|
|||||||
return config_;
|
return config_;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_db() -> meta_db & { return *db3_; }
|
[[nodiscard]] auto get_db() -> i_meta_db & { return *db3_; }
|
||||||
|
|
||||||
[[nodiscard]] auto get_db() const -> const meta_db & { return *db3_; }
|
[[nodiscard]] auto get_db() const -> const i_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,
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "providers/meta_db.hpp"
|
#include "db/sqlite_meta_db.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "utils/db/sqlite/db_common.hpp"
|
#include "utils/db/sqlite/db_common.hpp"
|
||||||
@ -31,7 +31,7 @@
|
|||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
meta_db::meta_db(const app_config &cfg) {
|
sqlite_meta_db::sqlite_meta_db(const app_config &cfg) {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
const std::map<std::string, std::string> sql_create_tables{
|
const std::map<std::string, std::string> sql_create_tables{
|
||||||
@ -55,10 +55,10 @@ meta_db::meta_db(const app_config &cfg) {
|
|||||||
sql_create_tables);
|
sql_create_tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_db::~meta_db() { db_.reset(); }
|
sqlite_meta_db::~sqlite_meta_db() { db_.reset(); }
|
||||||
|
|
||||||
auto meta_db::get_api_path(const std::string &source_path,
|
auto sqlite_meta_db::get_api_path(const std::string &source_path,
|
||||||
std::string &api_path) -> api_error {
|
std::string &api_path) const -> api_error {
|
||||||
auto result = utils::db::sqlite::db_select{*db_, table_name}
|
auto result = utils::db::sqlite::db_select{*db_, table_name}
|
||||||
.column("api_path")
|
.column("api_path")
|
||||||
.where("source_path")
|
.where("source_path")
|
||||||
@ -76,7 +76,7 @@ auto meta_db::get_api_path(const std::string &source_path,
|
|||||||
return api_error::item_not_found;
|
return api_error::item_not_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto meta_db::get_api_path_list() -> std::vector<std::string> {
|
auto sqlite_meta_db::get_api_path_list() const -> std::vector<std::string> {
|
||||||
std::vector<std::string> ret{};
|
std::vector<std::string> ret{};
|
||||||
|
|
||||||
auto result =
|
auto result =
|
||||||
@ -91,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, api_meta_map &meta)
|
auto sqlite_meta_db::get_item_meta(const std::string &api_path,
|
||||||
-> api_error {
|
api_meta_map &meta) const -> 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}
|
||||||
@ -131,7 +131,8 @@ auto meta_db::get_item_meta(const std::string &api_path, api_meta_map &meta)
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto meta_db::get_item_meta(const std::string &api_path, const std::string &key,
|
auto sqlite_meta_db::get_item_meta(const std::string &api_path,
|
||||||
|
const std::string &key,
|
||||||
std::string &value) const -> api_error {
|
std::string &value) const -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
@ -176,7 +177,7 @@ auto meta_db::get_item_meta(const std::string &api_path, const std::string &key,
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto meta_db::get_pinned_files() const -> std::vector<std::string> {
|
auto sqlite_meta_db::get_pinned_files() const -> std::vector<std::string> {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
std::vector<std::string> ret{};
|
std::vector<std::string> ret{};
|
||||||
@ -200,7 +201,7 @@ auto meta_db::get_pinned_files() const -> std::vector<std::string> {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto meta_db::get_total_item_count() const -> std::uint64_t {
|
auto sqlite_meta_db::get_total_item_count() const -> std::uint64_t {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
std::uint64_t ret{};
|
std::uint64_t ret{};
|
||||||
@ -223,7 +224,7 @@ 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 {
|
auto sqlite_meta_db::get_total_size() const -> std::uint64_t {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -245,7 +246,7 @@ auto meta_db::get_total_size() const -> std::uint64_t {
|
|||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
void meta_db::remove_api_path(const std::string &api_path) {
|
void sqlite_meta_db::remove_api_path(const std::string &api_path) {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
auto result = utils::db::sqlite::db_delete{*db_, table_name}
|
auto result = utils::db::sqlite::db_delete{*db_, table_name}
|
||||||
@ -258,7 +259,7 @@ void meta_db::remove_api_path(const std::string &api_path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto meta_db::remove_item_meta(const std::string &api_path,
|
auto sqlite_meta_db::remove_item_meta(const std::string &api_path,
|
||||||
const std::string &key) -> api_error {
|
const std::string &key) -> api_error {
|
||||||
api_meta_map meta{};
|
api_meta_map meta{};
|
||||||
auto res = get_item_meta(api_path, meta);
|
auto res = get_item_meta(api_path, meta);
|
||||||
@ -270,8 +271,9 @@ auto meta_db::remove_item_meta(const std::string &api_path,
|
|||||||
return update_item_meta(api_path, meta);
|
return update_item_meta(api_path, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto meta_db::rename_item_meta(const std::string &from_api_path,
|
auto sqlite_meta_db::rename_item_meta(const std::string &from_api_path,
|
||||||
const std::string &to_api_path) -> api_error {
|
const std::string &to_api_path)
|
||||||
|
-> api_error {
|
||||||
api_meta_map meta{};
|
api_meta_map meta{};
|
||||||
auto res = get_item_meta(from_api_path, meta);
|
auto res = get_item_meta(from_api_path, meta);
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
@ -282,12 +284,13 @@ auto meta_db::rename_item_meta(const std::string &from_api_path,
|
|||||||
return update_item_meta(to_api_path, meta);
|
return update_item_meta(to_api_path, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto meta_db::set_item_meta(const std::string &api_path, const std::string &key,
|
auto sqlite_meta_db::set_item_meta(const std::string &api_path,
|
||||||
|
const std::string &key,
|
||||||
const std::string &value) -> api_error {
|
const std::string &value) -> api_error {
|
||||||
return set_item_meta(api_path, {{key, value}});
|
return set_item_meta(api_path, {{key, value}});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto meta_db::set_item_meta(const std::string &api_path,
|
auto sqlite_meta_db::set_item_meta(const std::string &api_path,
|
||||||
const api_meta_map &meta) -> api_error {
|
const api_meta_map &meta) -> api_error {
|
||||||
api_meta_map existing_meta{};
|
api_meta_map existing_meta{};
|
||||||
if (get_item_meta(api_path, existing_meta) != api_error::success) {
|
if (get_item_meta(api_path, existing_meta) != api_error::success) {
|
||||||
@ -301,8 +304,8 @@ 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, api_meta_map meta)
|
auto sqlite_meta_db::update_item_meta(const std::string &api_path,
|
||||||
-> api_error {
|
api_meta_map meta) -> 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]);
|
@ -22,6 +22,7 @@
|
|||||||
#include "providers/base_provider.hpp"
|
#include "providers/base_provider.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
|
#include "db/meta_db.hpp"
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system.hpp"
|
||||||
#include "events/events.hpp"
|
#include "events/events.hpp"
|
||||||
#include "file_manager/i_file_manager.hpp"
|
#include "file_manager/i_file_manager.hpp"
|
||||||
@ -716,7 +717,7 @@ auto base_provider::start(api_item_added_callback api_item_added,
|
|||||||
api_item_added_ = api_item_added;
|
api_item_added_ = api_item_added;
|
||||||
fm_ = mgr;
|
fm_ = mgr;
|
||||||
|
|
||||||
db3_ = std::make_unique<meta_db>(config_);
|
db3_ = create_meta_db(config_);
|
||||||
|
|
||||||
api_meta_map meta{};
|
api_meta_map meta{};
|
||||||
if (get_item_meta("/", meta) == api_error::item_not_found) {
|
if (get_item_meta("/", meta) == api_error::item_not_found) {
|
||||||
|
@ -27,10 +27,11 @@
|
|||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "comm/curl/curl_comm.hpp"
|
#include "comm/curl/curl_comm.hpp"
|
||||||
|
#include "db/i_meta_db.hpp"
|
||||||
|
#include "db/meta_db.hpp"
|
||||||
#include "drives/fuse/fuse_drive.hpp"
|
#include "drives/fuse/fuse_drive.hpp"
|
||||||
#include "platform/platform.hpp"
|
#include "platform/platform.hpp"
|
||||||
#include "providers/encrypt/encrypt_provider.hpp"
|
#include "providers/encrypt/encrypt_provider.hpp"
|
||||||
#include "providers/meta_db.hpp"
|
|
||||||
#include "providers/s3/s3_provider.hpp"
|
#include "providers/s3/s3_provider.hpp"
|
||||||
#include "providers/sia/sia_provider.hpp"
|
#include "providers/sia/sia_provider.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
@ -76,7 +77,7 @@ public:
|
|||||||
static provider_type current_provider;
|
static provider_type current_provider;
|
||||||
static std::vector<std::string> drive_args;
|
static std::vector<std::string> drive_args;
|
||||||
static std::vector<std::string> drive_args2;
|
static std::vector<std::string> drive_args2;
|
||||||
static std::unique_ptr<meta_db> meta;
|
static std::unique_ptr<i_meta_db> meta;
|
||||||
static std::string mount_location;
|
static std::string mount_location;
|
||||||
static std::string mount_location2;
|
static std::string mount_location2;
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ protected:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
meta = std::make_unique<meta_db>(*config);
|
meta = create_meta_db(*config);
|
||||||
execute_mount(drive_args, mount_location);
|
execute_mount(drive_args, mount_location);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -164,7 +165,7 @@ protected:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
meta = std::make_unique<meta_db>(*config);
|
meta = create_meta_db(*config);
|
||||||
execute_mount(drive_args, mount_location);
|
execute_mount(drive_args, mount_location);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -257,8 +258,8 @@ public:
|
|||||||
return file_path;
|
return file_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto create_file_and_test(std::string &file_name,
|
static auto create_file_and_test(std::string &file_name, mode_t perms)
|
||||||
mode_t perms) -> std::string {
|
-> std::string {
|
||||||
file_name += std::to_string(++idx);
|
file_name += std::to_string(++idx);
|
||||||
auto file_path = utils::path::combine(mount_location, {file_name});
|
auto file_path = utils::path::combine(mount_location, {file_name});
|
||||||
|
|
||||||
@ -288,8 +289,8 @@ public:
|
|||||||
return create_file_and_test(file_name, ACCESSPERMS);
|
return create_file_and_test(file_name, ACCESSPERMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto create_directory_and_test(std::string &dir_name,
|
static auto create_directory_and_test(std::string &dir_name, mode_t perms)
|
||||||
mode_t perms) -> std::string {
|
-> std::string {
|
||||||
dir_name += std::to_string(++idx);
|
dir_name += std::to_string(++idx);
|
||||||
|
|
||||||
auto dir_path = utils::path::combine(mount_location, {dir_name});
|
auto dir_path = utils::path::combine(mount_location, {dir_name});
|
||||||
@ -391,7 +392,7 @@ template <typename provider_t>
|
|||||||
std::vector<std::string> fuse_test<provider_t>::drive_args2;
|
std::vector<std::string> fuse_test<provider_t>::drive_args2;
|
||||||
|
|
||||||
template <typename provider_t>
|
template <typename provider_t>
|
||||||
std::unique_ptr<meta_db> fuse_test<provider_t>::meta{};
|
std::unique_ptr<i_meta_db> fuse_test<provider_t>::meta{};
|
||||||
|
|
||||||
template <typename provider_t>
|
template <typename provider_t>
|
||||||
std::string fuse_test<provider_t>::mount_location;
|
std::string fuse_test<provider_t>::mount_location;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user