From 9c9c7cdf8b1e029a8bf66c991bdcfbd3ec15834f Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sun, 8 Dec 2024 11:55:32 -0600 Subject: [PATCH] file mgr db unit tests and fixes --- .../librepertory/src/db/sqlite_file_mgr_db.cpp | 2 +- .../src/file_manager/file_manager.cpp | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/repertory/librepertory/src/db/sqlite_file_mgr_db.cpp b/repertory/librepertory/src/db/sqlite_file_mgr_db.cpp index ea6045fa..83535d39 100644 --- a/repertory/librepertory/src/db/sqlite_file_mgr_db.cpp +++ b/repertory/librepertory/src/db/sqlite_file_mgr_db.cpp @@ -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) diff --git a/repertory/librepertory/src/file_manager/file_manager.cpp b/repertory/librepertory/src/file_manager/file_manager.cpp index 914b2a4c..17ac8aad 100644 --- a/repertory/librepertory/src/file_manager/file_manager.cpp +++ b/repertory/librepertory/src/file_manager/file_manager.cpp @@ -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(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");