restrict:添加不能update和down自己的文件限制。
This commit is contained in:
parent
fbb1ae43e8
commit
e825387201
@ -136,8 +136,14 @@ bool CClient::down_task(const std::string& param)
|
|||||||
logger_->error("No matched id[{}] in task list.", id);
|
logger_->error("No matched id[{}] in task list.", id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
down_ = std::make_shared<TransInfomation>();
|
|
||||||
|
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;
|
const auto& vec = task_list_[id]->files;
|
||||||
|
down_ = std::make_shared<TransInfomation>();
|
||||||
|
|
||||||
if (vec.empty()) {
|
if (vec.empty()) {
|
||||||
logger_->warn("No files List, Please Check!");
|
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);
|
logger_->error("No Index Found {}.", index);
|
||||||
return false;
|
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文件
|
// 读取list文件
|
||||||
std::ifstream in(COfPath::to_full(list_file));
|
std::ifstream in(COfPath::to_full(list_file));
|
||||||
if (!in.is_open()) {
|
if (!in.is_open()) {
|
||||||
@ -454,6 +467,7 @@ void CClient::handle_frame(CFrameBuffer* buf)
|
|||||||
switch (buf->type_) {
|
switch (buf->type_) {
|
||||||
case TYPE_GET_ID: {
|
case TYPE_GET_ID: {
|
||||||
logger_->debug("Your ID:{}", buf->tid_);
|
logger_->debug("Your ID:{}", buf->tid_);
|
||||||
|
own_id_ = buf->tid_;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TYPE_GET_LIST: {
|
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);
|
logger_->error("Stop Trans {} To {} failed.", t->cur_file_, str_key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
// std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->type_ = TYPE_TRANS_DONE;
|
buf->type_ = TYPE_TRANS_DONE;
|
||||||
|
@ -86,6 +86,7 @@ private:
|
|||||||
std::string list_file_;
|
std::string list_file_;
|
||||||
std::string list_serve_id_;
|
std::string list_serve_id_;
|
||||||
std::thread update_list_th_;
|
std::thread update_list_th_;
|
||||||
|
std::string own_id_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
class CFileOpr
|
class CFileOpr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user