From 25c445b88919f5f8d55c4507e22e382a6f5ae564 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Wed, 25 Sep 2024 18:47:36 -0500 Subject: [PATCH 1/2] removed is_processing check --- repertory/librepertory/src/file_manager/file_manager.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/repertory/librepertory/src/file_manager/file_manager.cpp b/repertory/librepertory/src/file_manager/file_manager.cpp index 296a8a27..4757ad31 100644 --- a/repertory/librepertory/src/file_manager/file_manager.cpp +++ b/repertory/librepertory/src/file_manager/file_manager.cpp @@ -765,11 +765,6 @@ auto file_manager::rename_file(const std::string &from_api_path, return api_error::file_in_use; } - // Don't rename if destination file is uploading or downloading - if (is_processing(to_api_path)) { - return api_error::file_in_use; - } - // Handle destination file exists (should overwrite) if (dest_exists) { filesystem_item fsi{}; From 5bd780ef07af32ad8ca3272bd9c15eef3f8e32a9 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Wed, 25 Sep 2024 21:24:56 -0500 Subject: [PATCH 2/2] updates --- .../src/file_manager/file_manager.cpp | 48 +++++++------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/repertory/librepertory/src/file_manager/file_manager.cpp b/repertory/librepertory/src/file_manager/file_manager.cpp index 4757ad31..fb295b14 100644 --- a/repertory/librepertory/src/file_manager/file_manager.cpp +++ b/repertory/librepertory/src/file_manager/file_manager.cpp @@ -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(); - 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); }