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);
|
||||
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;
|
||||
down_ = std::make_shared<TransInfomation>();
|
||||
|
||||
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: {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user