This commit is contained in:
Scott E. Graves 2024-10-02 11:11:57 -05:00
parent 366fe60e2f
commit 3e6ed45562

View File

@ -378,30 +378,27 @@ auto file_manager::get_stored_downloads() const -> std::vector<json> {
auto file_manager::handle_file_rename(const std::string &from_api_path, auto file_manager::handle_file_rename(const std::string &from_api_path,
const std::string &to_api_path) const std::string &to_api_path)
-> api_error { -> api_error {
auto should_upload{false};
std::string source_path{}; std::string source_path{};
auto file_iter = open_file_lookup_.find(from_api_path); auto file_iter = open_file_lookup_.find(from_api_path);
if (file_iter != open_file_lookup_.end()) { if (file_iter != open_file_lookup_.end()) {
source_path = file_iter->second->get_source_path(); source_path = file_iter->second->get_source_path();
} }
if (not should_upload) { auto should_upload{upload_lookup_.contains(from_api_path)};
should_upload = upload_lookup_.contains(from_api_path); if (should_upload) {
if (should_upload) { if (source_path.empty()) {
if (source_path.empty()) { source_path = upload_lookup_.at(from_api_path)->get_source_path();
source_path = upload_lookup_.at(from_api_path)->get_source_path(); }
} } else {
} else { auto result = db::db_select{*db_.get(), upload_table}
auto result = db::db_select{*db_.get(), upload_table} .column("source_path")
.column("source_path") .where("api_path")
.where("api_path") .equals(from_api_path)
.equals(from_api_path) .go();
.go(); std::optional<db::db_select::row> row;
std::optional<db::db_select::row> row; should_upload = result.get_row(row) && row.has_value();
should_upload = result.get_row(row) && row.has_value(); if (should_upload && source_path.empty()) {
if (should_upload && source_path.empty()) { source_path = row->get_column("source_path").get_value<std::string>();
source_path = row->get_column("source_path").get_value<std::string>();
}
} }
} }