2 Commits

Author SHA1 Message Date
55a88e7576 file mgr db unit tests and fixes
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2024-12-08 12:02:55 -06:00
9c9c7cdf8b file mgr db unit tests and fixes 2024-12-08 11:55:32 -06:00
2 changed files with 9 additions and 9 deletions

View File

@ -106,7 +106,7 @@ auto sqlite_file_mgr_db::add_upload(upload_entry entry) -> bool {
}
auto sqlite_file_mgr_db::add_upload_active(upload_active_entry entry) -> bool {
return utils::db::sqlite::db_insert{*db_, upload_table}
return utils::db::sqlite::db_insert{*db_, upload_active_table}
.or_replace()
.column_value("api_path", entry.api_path)
.column_value("source_path", entry.source_path)
@ -192,7 +192,6 @@ auto sqlite_file_mgr_db::get_resume_list() const -> std::vector<resume_entry> {
auto sqlite_file_mgr_db::get_upload(const std::string &api_path) const
-> std::optional<upload_entry> {
auto result = utils::db::sqlite::db_select{*db_, upload_table}
.column("source_path")
.where("api_path")
.equals(api_path)
.go();

View File

@ -424,7 +424,7 @@ void file_manager::queue_upload(const std::string &api_path,
remove_upload(api_path, true);
if (mgr_db_->add_upload({
if (mgr_db_->add_upload(i_file_mgr_db::upload_entry{
api_path,
utils::time::get_time_now(),
source_path,
@ -499,7 +499,7 @@ void file_manager::remove_upload(const std::string &api_path, bool no_lock) {
function_name, api_path, api_error::error, "failed to remove upload");
}
auto removed = not mgr_db_->remove_upload_active(api_path);
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,
@ -796,7 +796,7 @@ void file_manager::store_resume(const i_open_file &file) {
return;
}
if (mgr_db_->add_resume({
if (mgr_db_->add_resume(i_file_mgr_db::resume_entry{
file.get_api_path(),
file.get_chunk_size(),
file.get_read_state(),
@ -905,10 +905,11 @@ void file_manager::upload_handler() {
upload_lookup_[fsi.api_path] =
std::make_unique<upload>(fsi, provider_);
if (mgr_db_->remove_upload(entry->api_path)) {
if (not mgr_db_->add_upload_active({
entry->api_path,
entry->source_path,
})) {
if (not mgr_db_->add_upload_active(
i_file_mgr_db::upload_active_entry{
entry->api_path,
entry->source_path,
})) {
utils::error::raise_api_path_error(
function_name, entry->api_path, entry->source_path,
"failed to add to upload_active table");