Compare commits
13 Commits
8c9c7254b4
...
3a52dfc4ea
Author | SHA1 | Date | |
---|---|---|---|
3a52dfc4ea | |||
b8b364f292 | |||
a995afa6eb | |||
7415f562ff | |||
3425619773 | |||
1e8a351f67 | |||
2ff18fe98d | |||
06380ccc58 | |||
d93204bfe6 | |||
3b87050dcb | |||
6da907910c | |||
2493a16828 | |||
1bbe5fbef4 |
@ -1,9 +1,7 @@
|
||||
if(PROJECT_ENABLE_ROCKSDB)
|
||||
if(PROJECT_BUILD)
|
||||
add_definitions(-DPROJECT_ENABLE_ROCKSDB)
|
||||
|
||||
find_library(ROCKSDB_LIBRARY NAMES librocksdb.a REQUIRED)
|
||||
|
||||
link_libraries(${ROCKSDB_LIBRARY})
|
||||
elseif(NOT PROJECT_IS_MINGW OR CMAKE_HOST_WIN32)
|
||||
ExternalProject_Add(rocksdb_project
|
||||
@ -12,11 +10,11 @@ if(PROJECT_ENABLE_ROCKSDB)
|
||||
URL_HASH SHA256=${ROCKSDB_HASH}
|
||||
LIST_SEPARATOR |
|
||||
CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS}
|
||||
-DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS}
|
||||
-DBUILD_SHARED_LIBS=OFF
|
||||
-DBUILD_STATIC_LIBS=ON
|
||||
-DFAIL_ON_WARNINGS=OFF
|
||||
-DPORTABLE=1
|
||||
-DROCKSDB_BUILD_SHARED=${PROJECT_BUILD_SHARED_LIBS}
|
||||
-DROCKSDB_BUILD_SHARED=OFF
|
||||
-DROCKSDB_INSTALL_ON_WINDOWS=ON
|
||||
-DWITH_BENCHMARK=OFF
|
||||
-DWITH_BENCHMARK_TOOLS=OFF
|
||||
|
@ -43,7 +43,6 @@ public:
|
||||
|
||||
struct upload_entry final {
|
||||
std::string api_path;
|
||||
std::uint64_t date_time{};
|
||||
std::string source_path;
|
||||
};
|
||||
|
||||
@ -52,35 +51,35 @@ public:
|
||||
|
||||
[[nodiscard]] virtual auto add_upload(upload_entry entry) -> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
add_upload_active(upload_active_entry entry) -> bool = 0;
|
||||
[[nodiscard]] virtual auto add_upload_active(upload_active_entry entry)
|
||||
-> bool = 0;
|
||||
|
||||
virtual void clear() = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
get_next_upload() const -> std::optional<upload_entry> = 0;
|
||||
[[nodiscard]] virtual auto get_next_upload() const
|
||||
-> std::optional<upload_entry> = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
get_resume_list() const -> std::vector<resume_entry> = 0;
|
||||
[[nodiscard]] virtual auto get_resume_list() const
|
||||
-> std::vector<resume_entry> = 0;
|
||||
|
||||
[[nodiscard]] virtual auto get_upload(const std::string &api_path) const
|
||||
-> std::optional<upload_entry> = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
get_upload_active_list() const -> std::vector<upload_active_entry> = 0;
|
||||
[[nodiscard]] virtual auto get_upload_active_list() const
|
||||
-> std::vector<upload_active_entry> = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
remove_resume(const std::string &api_path) -> bool = 0;
|
||||
[[nodiscard]] virtual auto remove_resume(const std::string &api_path)
|
||||
-> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
remove_upload(const std::string &api_path) -> bool = 0;
|
||||
[[nodiscard]] virtual auto remove_upload(const std::string &api_path)
|
||||
-> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
remove_upload_active(const std::string &api_path) -> bool = 0;
|
||||
[[nodiscard]] virtual auto remove_upload_active(const std::string &api_path)
|
||||
-> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
rename_resume(const std::string &from_api_path,
|
||||
const std::string &to_api_path) -> bool = 0;
|
||||
[[nodiscard]] virtual auto rename_resume(const std::string &from_api_path,
|
||||
const std::string &to_api_path)
|
||||
-> bool = 0;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DB_RDB_FILE_MGR_DB_HPP_
|
||||
#define REPERTORY_INCLUDE_DB_RDB_FILE_MGR_DB_HPP_
|
||||
#ifndef REPERTORY_INCLUDE_DB_IMPL_RDB_FILE_MGR_DB_HPP_
|
||||
#define REPERTORY_INCLUDE_DB_IMPL_RDB_FILE_MGR_DB_HPP_
|
||||
|
||||
#include "db/i_file_mgr_db.hpp"
|
||||
|
||||
@ -62,37 +62,37 @@ public:
|
||||
|
||||
[[nodiscard]] auto add_upload(upload_entry entry) -> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
add_upload_active(upload_active_entry entry) -> bool override;
|
||||
[[nodiscard]] auto add_upload_active(upload_active_entry entry)
|
||||
-> bool override;
|
||||
|
||||
void clear() override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_next_upload() const -> std::optional<upload_entry> override;
|
||||
[[nodiscard]] auto get_next_upload() const
|
||||
-> std::optional<upload_entry> override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_resume_list() const -> std::vector<resume_entry> override;
|
||||
[[nodiscard]] auto get_resume_list() const
|
||||
-> std::vector<resume_entry> override;
|
||||
|
||||
[[nodiscard]] auto get_upload(const std::string &api_path) const
|
||||
-> std::optional<upload_entry> override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_upload_active_list() const -> std::vector<upload_active_entry> override;
|
||||
[[nodiscard]] auto get_upload_active_list() const
|
||||
-> std::vector<upload_active_entry> override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
remove_resume(const std::string &api_path) -> bool override;
|
||||
[[nodiscard]] auto remove_resume(const std::string &api_path)
|
||||
-> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
remove_upload(const std::string &api_path) -> bool override;
|
||||
[[nodiscard]] auto remove_upload(const std::string &api_path)
|
||||
-> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
remove_upload_active(const std::string &api_path) -> bool override;
|
||||
[[nodiscard]] auto remove_upload_active(const std::string &api_path)
|
||||
-> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
rename_resume(const std::string &from_api_path,
|
||||
const std::string &to_api_path) -> bool override;
|
||||
[[nodiscard]] auto rename_resume(const std::string &from_api_path,
|
||||
const std::string &to_api_path)
|
||||
-> bool override;
|
||||
};
|
||||
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DB_RDB_FILE_MGR_DB_HPP_
|
||||
#endif // REPERTORY_INCLUDE_DB_IMPL_RDB_FILE_MGR_DB_HPP_
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DB_RDB_META_DB_HPP_
|
||||
#define REPERTORY_INCLUDE_DB_RDB_META_DB_HPP_
|
||||
#ifndef REPERTORY_INCLUDE_DB_IMPL_RDB_META_DB_HPP_
|
||||
#define REPERTORY_INCLUDE_DB_IMPL_RDB_META_DB_HPP_
|
||||
|
||||
#include "db/i_meta_db.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
@ -109,4 +109,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DB_RDB_META_DB_HPP_
|
||||
#endif // REPERTORY_INCLUDE_DB_IMPL_RDB_META_DB_HPP_
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DB_SQLITE_FILE_MGR_DB_HPP_
|
||||
#define REPERTORY_INCLUDE_DB_SQLITE_FILE_MGR_DB_HPP_
|
||||
#ifndef REPERTORY_INCLUDE_DB_IMPL_SQLITE_FILE_MGR_DB_HPP_
|
||||
#define REPERTORY_INCLUDE_DB_IMPL_SQLITE_FILE_MGR_DB_HPP_
|
||||
|
||||
#include "db/i_file_mgr_db.hpp"
|
||||
#include "utils/db/sqlite/db_common.hpp"
|
||||
@ -46,37 +46,37 @@ public:
|
||||
|
||||
[[nodiscard]] auto add_upload(upload_entry entry) -> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
add_upload_active(upload_active_entry entry) -> bool override;
|
||||
[[nodiscard]] auto add_upload_active(upload_active_entry entry)
|
||||
-> bool override;
|
||||
|
||||
void clear() override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_next_upload() const -> std::optional<upload_entry> override;
|
||||
[[nodiscard]] auto get_next_upload() const
|
||||
-> std::optional<upload_entry> override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_resume_list() const -> std::vector<resume_entry> override;
|
||||
[[nodiscard]] auto get_resume_list() const
|
||||
-> std::vector<resume_entry> override;
|
||||
|
||||
[[nodiscard]] auto get_upload(const std::string &api_path) const
|
||||
-> std::optional<upload_entry> override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_upload_active_list() const -> std::vector<upload_active_entry> override;
|
||||
[[nodiscard]] auto get_upload_active_list() const
|
||||
-> std::vector<upload_active_entry> override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
remove_resume(const std::string &api_path) -> bool override;
|
||||
[[nodiscard]] auto remove_resume(const std::string &api_path)
|
||||
-> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
remove_upload(const std::string &api_path) -> bool override;
|
||||
[[nodiscard]] auto remove_upload(const std::string &api_path)
|
||||
-> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
remove_upload_active(const std::string &api_path) -> bool override;
|
||||
[[nodiscard]] auto remove_upload_active(const std::string &api_path)
|
||||
-> bool override;
|
||||
|
||||
[[nodiscard]] auto
|
||||
rename_resume(const std::string &from_api_path,
|
||||
const std::string &to_api_path) -> bool override;
|
||||
[[nodiscard]] auto rename_resume(const std::string &from_api_path,
|
||||
const std::string &to_api_path)
|
||||
-> bool override;
|
||||
};
|
||||
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DB_SQLITE_FILE_MGR_DB_HPP_
|
||||
#endif // REPERTORY_INCLUDE_DB_IMPL_SQLITE_FILE_MGR_DB_HPP_
|
@ -19,8 +19,8 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef REPERTORY_INCLUDE_DB_SQLITE_META_DB_HPP_
|
||||
#define REPERTORY_INCLUDE_DB_SQLITE_META_DB_HPP_
|
||||
#ifndef REPERTORY_INCLUDE_DB_IMPL_SQLITE_META_DB_HPP_
|
||||
#define REPERTORY_INCLUDE_DB_IMPL_SQLITE_META_DB_HPP_
|
||||
|
||||
#include "db/i_meta_db.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
@ -94,4 +94,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DB_SQLITE_META_DB_HPP_
|
||||
#endif // REPERTORY_INCLUDE_DB_IMPL_SQLITE_META_DB_HPP_
|
@ -23,12 +23,12 @@
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "db/i_file_mgr_db.hpp"
|
||||
#include "db/rdb_file_mgr_db.hpp"
|
||||
#include "db/sqlite_file_mgr_db.hpp"
|
||||
#include "db/impl/rdb_file_mgr_db.hpp"
|
||||
#include "db/impl/sqlite_file_mgr_db.hpp"
|
||||
|
||||
namespace repertory {
|
||||
auto create_file_mgr_db(const app_config &cfg)
|
||||
-> std::unique_ptr<i_file_mgr_db> {
|
||||
return std::make_unique<sqlite_file_mgr_db>(cfg);
|
||||
return std::make_unique<rdb_file_mgr_db>(cfg);
|
||||
}
|
||||
} // namespace repertory
|
||||
|
@ -19,7 +19,7 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#include "db/rdb_file_mgr_db.hpp"
|
||||
#include "db/impl/rdb_file_mgr_db.hpp"
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "types/startup_exception.hpp"
|
||||
@ -33,8 +33,8 @@ namespace {
|
||||
[[nodiscard]] auto
|
||||
create_rocksdb(const repertory::app_config &cfg, const std::string &name,
|
||||
const std::vector<rocksdb::ColumnFamilyDescriptor> &families,
|
||||
std::vector<rocksdb::ColumnFamilyHandle *> &handles,
|
||||
bool clear) -> std::unique_ptr<rocksdb::DB> {
|
||||
std::vector<rocksdb::ColumnFamilyHandle *> &handles, bool clear)
|
||||
-> std::unique_ptr<rocksdb::DB> {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto path = repertory::utils::path::combine(cfg.get_data_directory(), {name});
|
||||
@ -104,19 +104,21 @@ auto rdb_file_mgr_db::add_upload(upload_entry entry) -> bool {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return perform_action(function_name, [this, &entry]() -> rocksdb::Status {
|
||||
auto data = json({
|
||||
{"date_time", entry.date_time},
|
||||
{"source_path", entry.source_path},
|
||||
});
|
||||
|
||||
return db_->Put(rocksdb::WriteOptions{}, upload_family_,
|
||||
utils::string::zero_pad(std::to_string(++id_), 19U) + '|' +
|
||||
utils::string::zero_pad(std::to_string(++id_), 20U) + '|' +
|
||||
entry.api_path,
|
||||
data.dump());
|
||||
entry.source_path);
|
||||
});
|
||||
}
|
||||
|
||||
auto rdb_file_mgr_db::add_upload_active(upload_active_entry entry) -> bool {}
|
||||
auto rdb_file_mgr_db::add_upload_active(upload_active_entry entry) -> bool {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return perform_action(function_name, [this, &entry]() -> rocksdb::Status {
|
||||
return db_->Put(rocksdb::WriteOptions{}, upload_active_family_,
|
||||
entry.api_path, entry.source_path);
|
||||
});
|
||||
}
|
||||
|
||||
void rdb_file_mgr_db::clear() { create_or_open(true); }
|
||||
|
||||
@ -126,11 +128,24 @@ auto rdb_file_mgr_db::create_iterator(rocksdb::ColumnFamilyHandle *family) const
|
||||
db_->NewIterator(rocksdb::ReadOptions(), family));
|
||||
}
|
||||
|
||||
auto rdb_file_mgr_db::get_next_upload() const -> std::optional<upload_entry> {}
|
||||
auto rdb_file_mgr_db::get_next_upload() const -> std::optional<upload_entry> {
|
||||
auto iter = create_iterator(upload_family_);
|
||||
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
|
||||
auto parts = utils::string::split(iter->key().ToString(), '|', false);
|
||||
parts.erase(parts.begin());
|
||||
|
||||
auto api_path = utils::string::join(parts, '|');
|
||||
|
||||
return upload_entry{
|
||||
api_path,
|
||||
iter->value().ToString(),
|
||||
};
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto rdb_file_mgr_db::get_resume_list() const -> std::vector<resume_entry> {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
std::vector<resume_entry> ret;
|
||||
|
||||
auto iter = create_iterator(resume_family_);
|
||||
@ -150,9 +165,7 @@ auto rdb_file_mgr_db::get_resume_list() const -> std::vector<resume_entry> {
|
||||
|
||||
auto rdb_file_mgr_db::get_upload(const std::string &api_path) const
|
||||
-> std::optional<upload_entry> {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
auto iter = create_iterator(upload_family_);
|
||||
|
||||
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
|
||||
auto parts = utils::string::split(iter->key().ToString(), '|', false);
|
||||
parts.erase(parts.begin());
|
||||
@ -161,11 +174,9 @@ auto rdb_file_mgr_db::get_upload(const std::string &api_path) const
|
||||
continue;
|
||||
}
|
||||
|
||||
auto data = json::parse(iter->value().ToString());
|
||||
return upload_entry{
|
||||
api_path,
|
||||
data.at("date_time").get<std::uint64_t>(),
|
||||
data.at("source_path").get<std::string>(),
|
||||
iter->value().ToString(),
|
||||
};
|
||||
}
|
||||
|
||||
@ -173,31 +184,74 @@ auto rdb_file_mgr_db::get_upload(const std::string &api_path) const
|
||||
}
|
||||
|
||||
auto rdb_file_mgr_db::get_upload_active_list() const
|
||||
-> std::vector<upload_active_entry> {}
|
||||
-> std::vector<upload_active_entry> {
|
||||
std::vector<upload_active_entry> ret;
|
||||
|
||||
auto iter = create_iterator(upload_active_family_);
|
||||
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
|
||||
ret.emplace_back(upload_active_entry{
|
||||
iter->key().ToString(),
|
||||
iter->value().ToString(),
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto rdb_file_mgr_db::perform_action(std::string_view function_name,
|
||||
std::function<rocksdb::Status()> action)
|
||||
-> bool {
|
||||
auto res = action();
|
||||
if (not res.ok()) {
|
||||
utils::error::raise_error(function_name, res.ToString());
|
||||
try {
|
||||
auto res = action();
|
||||
if (not res.ok()) {
|
||||
utils::error::raise_error(function_name, res.ToString());
|
||||
}
|
||||
|
||||
return res.ok();
|
||||
} catch (const std::exception &ex) {
|
||||
utils::error::raise_error(function_name, ex);
|
||||
}
|
||||
|
||||
return res.ok();
|
||||
return false;
|
||||
}
|
||||
|
||||
auto rdb_file_mgr_db::remove_resume(const std::string &api_path) -> bool {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return perform_action(function_name, [this, &api_path]() -> rocksdb::Status {
|
||||
return db_->Delete(rocksdb::WriteOptions{}, api_path);
|
||||
return db_->Delete(rocksdb::WriteOptions{}, resume_family_, api_path);
|
||||
});
|
||||
}
|
||||
|
||||
auto rdb_file_mgr_db::remove_upload(const std::string &api_path) -> bool {}
|
||||
auto rdb_file_mgr_db::remove_upload(const std::string &api_path) -> bool {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto iter = create_iterator(upload_family_);
|
||||
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
|
||||
auto parts = utils::string::split(iter->key().ToString(), '|', false);
|
||||
parts.erase(parts.begin());
|
||||
|
||||
if (api_path != utils::string::join(parts, '|')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return perform_action(function_name, [this, &iter]() -> rocksdb::Status {
|
||||
return db_->Delete(rocksdb::WriteOptions{}, upload_family_, iter->key());
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
auto rdb_file_mgr_db::remove_upload_active(const std::string &api_path)
|
||||
-> bool {}
|
||||
-> bool {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
return perform_action(function_name, [this, &api_path]() -> rocksdb::Status {
|
||||
return db_->Delete(rocksdb::WriteOptions{}, upload_active_family_,
|
||||
api_path);
|
||||
});
|
||||
}
|
||||
|
||||
auto rdb_file_mgr_db::rename_resume(const std::string &from_api_path,
|
||||
const std::string &to_api_path) -> bool {
|
@ -19,7 +19,7 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#include "db/rdb_meta_db.hpp"
|
||||
#include "db/impl/rdb_meta_db.hpp"
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "types/startup_exception.hpp"
|
@ -19,7 +19,7 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#include "db/sqlite_file_mgr_db.hpp"
|
||||
#include "db/impl/sqlite_file_mgr_db.hpp"
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "utils/config.hpp"
|
||||
@ -56,7 +56,6 @@ const std::map<std::string, std::string> sql_create_tables{
|
||||
"("
|
||||
"id INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||
"api_path TEXT UNIQUE, "
|
||||
"date_time INTEGER, "
|
||||
"source_path TEXT"
|
||||
");",
|
||||
},
|
||||
@ -99,7 +98,6 @@ auto sqlite_file_mgr_db::add_upload(upload_entry entry) -> bool {
|
||||
return utils::db::sqlite::db_insert{*db_, upload_table}
|
||||
.or_replace()
|
||||
.column_value("api_path", entry.api_path)
|
||||
.column_value("date_time", static_cast<std::int64_t>(entry.date_time))
|
||||
.column_value("source_path", entry.source_path)
|
||||
.go()
|
||||
.ok();
|
||||
@ -152,8 +150,6 @@ auto sqlite_file_mgr_db::get_next_upload() const
|
||||
|
||||
return upload_entry{
|
||||
row->get_column("api_path").get_value<std::string>(),
|
||||
static_cast<std::uint64_t>(
|
||||
row->get_column("date_time").get_value<std::int64_t>()),
|
||||
row->get_column("source_path").get_value<std::string>(),
|
||||
};
|
||||
}
|
||||
@ -202,8 +198,6 @@ auto sqlite_file_mgr_db::get_upload(const std::string &api_path) const
|
||||
|
||||
return upload_entry{
|
||||
row->get_column("api_path").get_value<std::string>(),
|
||||
static_cast<std::uint64_t>(
|
||||
row->get_column("date_time").get_value<std::int64_t>()),
|
||||
row->get_column("source_path").get_value<std::string>(),
|
||||
};
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#include "db/sqlite_meta_db.hpp"
|
||||
#include "db/impl/sqlite_meta_db.hpp"
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "utils/db/sqlite/db_common.hpp"
|
@ -22,8 +22,8 @@
|
||||
#include "db/meta_db.hpp"
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "db/rdb_meta_db.hpp"
|
||||
#include "db/sqlite_meta_db.hpp"
|
||||
#include "db/impl/rdb_meta_db.hpp"
|
||||
#include "db/impl/sqlite_meta_db.hpp"
|
||||
|
||||
namespace repertory {
|
||||
auto create_meta_db(const app_config &cfg) -> std::unique_ptr<i_meta_db> {
|
||||
|
@ -361,10 +361,11 @@ auto file_manager::open(const std::string &api_path, bool directory,
|
||||
return open(api_path, directory, ofd, handle, file, nullptr);
|
||||
}
|
||||
|
||||
auto file_manager::open(
|
||||
const std::string &api_path, bool directory, const open_file_data &ofd,
|
||||
std::uint64_t &handle, std::shared_ptr<i_open_file> &file,
|
||||
std::shared_ptr<i_closeable_open_file> closeable_file) -> api_error {
|
||||
auto file_manager::open(const std::string &api_path, bool directory,
|
||||
const open_file_data &ofd, std::uint64_t &handle,
|
||||
std::shared_ptr<i_open_file> &file,
|
||||
std::shared_ptr<i_closeable_open_file> closeable_file)
|
||||
-> api_error {
|
||||
const auto create_and_add_handle =
|
||||
[&](std::shared_ptr<i_closeable_open_file> cur_file) {
|
||||
handle = get_next_handle();
|
||||
@ -426,7 +427,6 @@ void file_manager::queue_upload(const std::string &api_path,
|
||||
|
||||
if (mgr_db_->add_upload(i_file_mgr_db::upload_entry{
|
||||
api_path,
|
||||
utils::time::get_time_now(),
|
||||
source_path,
|
||||
})) {
|
||||
remove_resume(api_path, source_path);
|
||||
@ -454,6 +454,9 @@ auto file_manager::remove_file(const std::string &api_path) -> api_error {
|
||||
|
||||
close_all(api_path);
|
||||
|
||||
remove_upload(api_path, true);
|
||||
remove_resume(api_path, fsi.source_path);
|
||||
|
||||
res = provider_.remove_file(api_path);
|
||||
if (res != api_error::success) {
|
||||
return res;
|
||||
@ -501,9 +504,9 @@ void file_manager::remove_upload(const std::string &api_path, bool no_lock) {
|
||||
|
||||
auto removed = mgr_db_->remove_upload_active(api_path);
|
||||
if (not removed) {
|
||||
utils::error::raise_api_path_error(
|
||||
function_name, api_path, api_error::error,
|
||||
"failed to remove from upload_active table");
|
||||
utils::error::raise_api_path_error(function_name, api_path,
|
||||
api_error::error,
|
||||
"failed to remove active upload");
|
||||
}
|
||||
|
||||
if (upload_lookup_.find(api_path) != upload_lookup_.end()) {
|
||||
@ -597,8 +600,8 @@ auto file_manager::rename_directory(const std::string &from_api_path,
|
||||
}
|
||||
|
||||
auto file_manager::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 {
|
||||
if (not provider_.is_rename_supported()) {
|
||||
return api_error::not_implemented;
|
||||
}
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include "test_common.hpp"
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "db/rdb_file_mgr_db.hpp"
|
||||
#include "db/sqlite_file_mgr_db.hpp"
|
||||
#include "db/impl/rdb_file_mgr_db.hpp"
|
||||
#include "db/impl/sqlite_file_mgr_db.hpp"
|
||||
#include "events/consumers/console_consumer.hpp"
|
||||
#include "events/event_system.hpp"
|
||||
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include "test_common.hpp"
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "db/rdb_meta_db.hpp"
|
||||
#include "db/sqlite_meta_db.hpp"
|
||||
#include "db/impl/rdb_meta_db.hpp"
|
||||
#include "db/impl/sqlite_meta_db.hpp"
|
||||
#include "events/consumers/console_consumer.hpp"
|
||||
#include "events/event_system.hpp"
|
||||
|
||||
|
@ -119,7 +119,6 @@ TYPED_TEST(file_mgr_db_test, can_add_get_and_remove_upload) {
|
||||
this->file_mgr_db->clear();
|
||||
EXPECT_TRUE(this->file_mgr_db->add_upload({
|
||||
"/test0",
|
||||
2ULL,
|
||||
"/src/test0",
|
||||
}));
|
||||
|
||||
@ -136,13 +135,11 @@ TYPED_TEST(file_mgr_db_test, uploads_are_correctly_ordered) {
|
||||
this->file_mgr_db->clear();
|
||||
EXPECT_TRUE(this->file_mgr_db->add_upload({
|
||||
"/test08",
|
||||
utils::time::get_time_now(),
|
||||
"/src/test0",
|
||||
}));
|
||||
|
||||
EXPECT_TRUE(this->file_mgr_db->add_upload({
|
||||
"/test07",
|
||||
utils::time::get_time_now(),
|
||||
"/src/test1",
|
||||
}));
|
||||
|
||||
|
@ -108,10 +108,6 @@ if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_STATIC_LINK}" == "OFF" ]; th
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libpugi*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_ROCKSDB}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/librocksdb*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SDL}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/SDL2*.dll)
|
||||
fi
|
||||
|
Reference in New Issue
Block a user