From 8889bd061db273ab99fd10aad609c50ec09dfe22 Mon Sep 17 00:00:00 2001 From: taynpg Date: Mon, 16 Dec 2024 13:54:54 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=AD=A3Linux=E4=B8=8B?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=87=E4=BB=B6=E5=90=8D=E4=B8=BA=E5=85=A8?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E7=9A=84=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=AD=A3Linux=E7=9A=84pthread=E5=BA=93?= =?UTF-8?q?=E6=9C=AA=E9=93=BE=E6=8E=A5=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/CMakeLists.txt | 5 ++++- client/client.cpp | 5 +++-- server/CMakeLists.txt | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 44e1f87..1be1123 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -9,4 +9,7 @@ if (MSVC) endif() add_executable(transmc main.cpp client.h client.cpp file_oper.h file_oper.cpp) -target_link_libraries(transmc PRIVATE trans_net trans_util) \ No newline at end of file +target_link_libraries(transmc PRIVATE trans_net trans_util) +if (UNIX) +target_link_libraries(transmc PRIVATE pthread) +endif() \ No newline at end of file diff --git a/client/client.cpp b/client/client.cpp index c3411f6..2d7f151 100644 --- a/client/client.cpp +++ b/client/client.cpp @@ -89,7 +89,6 @@ bool CClient::down_task(const std::string& param) // 开始传输文件 for (const auto& item : vec) { - logger_->warn("Start Down => {}", item); down_one_file(task_list_[id]->id, item); } return true; @@ -130,8 +129,9 @@ bool CClient::down_one_file(const std::string& id, const std::string& file) down_->cur_remote_id_ = id; down_->cur_remote_file_ = file; - fs::path remote_file(down_->cur_remote_file_); + fs::path remote_file(ofen::COfPath::normalize(down_->cur_remote_file_)); down_->cur_file_ = COfPath::to_full(remote_file.filename().string()); + logger_->warn("Start Down => {} To {}", file, down_->cur_file_); // 请求下载文件 std::shared_ptr buf = std::make_shared(); @@ -155,6 +155,7 @@ void CClient::cancel_trans_file(const std::string& key) if (key.empty()) { t = down_; } else { + std::lock_guard lock(mutex_); if (up_.count(key)) { t = up_[key]; } diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index b3689b3..2a72936 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -8,4 +8,7 @@ if (MSVC) endif() add_executable(transms main.cpp server.h server.cpp) -target_link_libraries(transms PRIVATE trans_net trans_util) \ No newline at end of file +target_link_libraries(transms PRIVATE trans_net trans_util) +if (UNIX) +target_link_libraries(transms PRIVATE pthread) +endif() \ No newline at end of file