refactor
This commit is contained in:
parent
366fe60e2f
commit
3e6ed45562
@ -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,
|
||||
const std::string &to_api_path)
|
||||
-> api_error {
|
||||
auto should_upload{false};
|
||||
std::string source_path{};
|
||||
auto file_iter = open_file_lookup_.find(from_api_path);
|
||||
if (file_iter != open_file_lookup_.end()) {
|
||||
source_path = file_iter->second->get_source_path();
|
||||
}
|
||||
|
||||
if (not should_upload) {
|
||||
should_upload = upload_lookup_.contains(from_api_path);
|
||||
if (should_upload) {
|
||||
if (source_path.empty()) {
|
||||
source_path = upload_lookup_.at(from_api_path)->get_source_path();
|
||||
}
|
||||
} else {
|
||||
auto result = db::db_select{*db_.get(), upload_table}
|
||||
.column("source_path")
|
||||
.where("api_path")
|
||||
.equals(from_api_path)
|
||||
.go();
|
||||
std::optional<db::db_select::row> row;
|
||||
should_upload = result.get_row(row) && row.has_value();
|
||||
if (should_upload && source_path.empty()) {
|
||||
source_path = row->get_column("source_path").get_value<std::string>();
|
||||
}
|
||||
auto should_upload{upload_lookup_.contains(from_api_path)};
|
||||
if (should_upload) {
|
||||
if (source_path.empty()) {
|
||||
source_path = upload_lookup_.at(from_api_path)->get_source_path();
|
||||
}
|
||||
} else {
|
||||
auto result = db::db_select{*db_.get(), upload_table}
|
||||
.column("source_path")
|
||||
.where("api_path")
|
||||
.equals(from_api_path)
|
||||
.go();
|
||||
std::optional<db::db_select::row> row;
|
||||
should_upload = result.get_row(row) && row.has_value();
|
||||
if (should_upload && source_path.empty()) {
|
||||
source_path = row->get_column("source_path").get_value<std::string>();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user