updates
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2024-09-25 21:24:56 -05:00
parent 25c445b889
commit 5bd780ef07

View File

@ -395,18 +395,20 @@ auto file_manager::handle_file_rename(const std::string &from_api_path,
should_upload = result.get_row(row) && row.has_value();
if (should_upload) {
source_path = row->get_column("source_path").get_value<std::string>();
remove_upload(from_api_path);
}
}
if (should_upload) {
remove_upload(from_api_path);
}
auto ret = provider_.rename_file(from_api_path, to_api_path);
if (ret == api_error::success) {
swap_renamed_items(from_api_path, to_api_path);
if (should_upload) {
queue_upload(to_api_path, source_path, false);
}
} else if (should_upload) {
queue_upload(from_api_path, source_path, false);
}
if (should_upload) {
queue_upload(to_api_path, source_path, false);
}
return ret;
@ -537,11 +539,6 @@ auto file_manager::remove_file(const std::string &api_path) -> api_error {
};
recur_mutex_lock open_lock(open_file_mtx_);
auto file_iter = open_file_lookup_.find(api_path);
if (file_iter != open_file_lookup_.end() &&
file_iter->second->is_modified()) {
return api_error::file_in_use;
}
filesystem_item fsi{};
auto res = provider_.get_filesystem_item(api_path, false, fsi);
@ -765,27 +762,6 @@ auto file_manager::rename_file(const std::string &from_api_path,
return api_error::file_in_use;
}
// Handle destination file exists (should overwrite)
if (dest_exists) {
filesystem_item fsi{};
res = provider_.get_filesystem_item(to_api_path, false, fsi);
if (res != api_error::success) {
return res;
}
res = remove_file(to_api_path);
if ((res == api_error::success) || (res == api_error::item_not_found)) {
if (not utils::file::file(fsi.source_path).remove()) {
utils::error::raise_api_path_error(
function_name, fsi.api_path, fsi.source_path,
utils::get_last_error_code(), "failed to delete source path");
}
return handle_file_rename(from_api_path, to_api_path);
}
return res;
}
// Check destination parent directory exists
res = provider_.is_directory(utils::path::get_parent_api_path(to_api_path),
exists);
@ -796,6 +772,14 @@ auto file_manager::rename_file(const std::string &from_api_path,
return api_error::directory_not_found;
}
// Handle destination file exists (should overwrite)
if (dest_exists) {
res = remove_file(to_api_path);
if ((res != api_error::success) && (res != api_error::item_not_found)) {
return res;
}
}
return handle_file_rename(from_api_path, to_api_path);
}