diff --git a/client/client.cpp b/client/client.cpp index 94a2233..3cc8783 100644 --- a/client/client.cpp +++ b/client/client.cpp @@ -136,8 +136,14 @@ bool CClient::down_task(const std::string& param) logger_->error("No matched id[{}] in task list.", id); return false; } - down_ = std::make_shared(); + + if (task_list_[id]->id == own_id_) { + logger_->warn("You can't down your own file!!!"); + return false; + } + const auto& vec = task_list_[id]->files; + down_ = std::make_shared(); if (vec.empty()) { logger_->warn("No files List, Please Check!"); @@ -336,6 +342,13 @@ bool CClient::request_update_list(const std::string& param) logger_->error("No Index Found {}.", index); return false; } + + const auto& sr = task_list_[index]; + if (sr->id == own_id_) { + logger_->warn("You can't update your own file!!!"); + return false; + } + // 读取list文件 std::ifstream in(COfPath::to_full(list_file)); if (!in.is_open()) { @@ -454,6 +467,7 @@ void CClient::handle_frame(CFrameBuffer* buf) switch (buf->type_) { case TYPE_GET_ID: { logger_->debug("Your ID:{}", buf->tid_); + own_id_ = buf->tid_; break; } case TYPE_GET_LIST: { @@ -658,7 +672,7 @@ void CClient::send_file_data_th(const char* keys) logger_->error("Stop Trans {} To {} failed.", t->cur_file_, str_key); return; } - //std::this_thread::sleep_for(std::chrono::milliseconds(10)); + // std::this_thread::sleep_for(std::chrono::milliseconds(10)); } buf->type_ = TYPE_TRANS_DONE; diff --git a/client/client.h b/client/client.h index 0984921..0020872 100644 --- a/client/client.h +++ b/client/client.h @@ -86,6 +86,7 @@ private: std::string list_file_; std::string list_serve_id_; std::thread update_list_th_; + std::string own_id_{}; }; class CFileOpr