fix:处理客户端A下载客户端B时在客户端缓存中未找到不能下载的问题。
This commit is contained in:
parent
d715719a00
commit
5bbe4f0ecd
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -21,7 +21,7 @@
|
|||||||
],
|
],
|
||||||
"visualizerFile": "${workspaceRoot}/.vscode/qt5.natvis",
|
"visualizerFile": "${workspaceRoot}/.vscode/qt5.natvis",
|
||||||
"args": [
|
"args": [
|
||||||
//"-u", "0"
|
"-u", "0"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"cmake.environment": {
|
"cmake.environment": {
|
||||||
|
@ -440,12 +440,19 @@ bool CClient::cmd_upload_files(const std::string& param)
|
|||||||
|
|
||||||
bool CClient::down_one_file(int remote_id, const std::string& file, const std::string& local_dir)
|
bool CClient::down_one_file(int remote_id, const std::string& file, const std::string& local_dir)
|
||||||
{
|
{
|
||||||
|
std::string ret_id{};
|
||||||
|
std::string ret_uuid{};
|
||||||
|
|
||||||
if (clients_.count(remote_id) == 0) {
|
if (clients_.count(remote_id) == 0) {
|
||||||
TLOGE("{} No Index Found {}.", __LINE__, remote_id);
|
TLOGW("{} No Index Found {}, Try {}", __LINE__, remote_id, list_server_id_);
|
||||||
return false;
|
ret_id = list_server_id_;
|
||||||
|
ret_uuid = list_server_uuid_;
|
||||||
|
} else {
|
||||||
|
ret_id = clients_[remote_id]->id;
|
||||||
|
ret_uuid = clients_[remote_id]->uuid;
|
||||||
}
|
}
|
||||||
auto client = clients_[remote_id];
|
|
||||||
down_->cur_remote_id_ = client->id;
|
down_->cur_remote_id_ = ret_id;
|
||||||
down_->cur_remote_file_ = file;
|
down_->cur_remote_file_ = file;
|
||||||
|
|
||||||
fs::path remote_file(ofen::COfPath::normalize(down_->cur_remote_file_));
|
fs::path remote_file(ofen::COfPath::normalize(down_->cur_remote_file_));
|
||||||
@ -456,7 +463,7 @@ bool CClient::down_one_file(int remote_id, const std::string& file, const std::s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 这里要先检查羁绊
|
// 这里要先检查羁绊
|
||||||
if (client->uuid == uuid_ && COfPath::is_same_dir(remote_file.string(), down_->cur_file_)) {
|
if (ret_uuid == uuid_ && COfPath::is_same_dir(remote_file.string(), down_->cur_file_)) {
|
||||||
// 处在同一个机器上的同目录下
|
// 处在同一个机器上的同目录下
|
||||||
TLOGE("You Can't Operate File In Same Dir And In Same Machine.", down_->cur_remote_file_);
|
TLOGE("You Can't Operate File In Same Dir And In Same Machine.", down_->cur_remote_file_);
|
||||||
return false;
|
return false;
|
||||||
@ -471,7 +478,7 @@ bool CClient::down_one_file(int remote_id, const std::string& file, const std::s
|
|||||||
// 请求下载文件
|
// 请求下载文件
|
||||||
std::shared_ptr<CFrameBuffer> buf = std::make_shared<CFrameBuffer>();
|
std::shared_ptr<CFrameBuffer> buf = std::make_shared<CFrameBuffer>();
|
||||||
buf->type_ = TYPE_OPEN_FILE;
|
buf->type_ = TYPE_OPEN_FILE;
|
||||||
buf->tid_ = client->id;
|
buf->tid_ = ret_id;
|
||||||
CMessageInfo msg_info(own_id_);
|
CMessageInfo msg_info(own_id_);
|
||||||
msg_info.str = file;
|
msg_info.str = file;
|
||||||
serialize(msg_info, &buf->data_, buf->len_);
|
serialize(msg_info, &buf->data_, buf->len_);
|
||||||
@ -690,13 +697,13 @@ bool CClient::variable_and_parse_files(const std::string& content, std::map<std:
|
|||||||
bool CClient::down_update_file(const std::map<std::string, std::string>& files)
|
bool CClient::down_update_file(const std::map<std::string, std::string>& files)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CFrameBuffer> buf = std::make_shared<CFrameBuffer>();
|
std::shared_ptr<CFrameBuffer> buf = std::make_shared<CFrameBuffer>();
|
||||||
buf->tid_ = list_serve_id_;
|
buf->tid_ = list_server_id_;
|
||||||
down_ = std::make_shared<TransInfomation>();
|
down_ = std::make_shared<TransInfomation>();
|
||||||
bool suc = true;
|
bool suc = true;
|
||||||
|
|
||||||
int id = -1;
|
int id = -1;
|
||||||
for (const auto& item : clients_) {
|
for (const auto& item : clients_) {
|
||||||
if (item.second->id == list_serve_id_) {
|
if (item.second->id == list_server_id_) {
|
||||||
id = item.first;
|
id = item.first;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1206,6 +1213,7 @@ void CClient::handle_frame(CFrameBuffer* buf)
|
|||||||
}
|
}
|
||||||
if (variable_and_parse_files(msg_info.str, files)) {
|
if (variable_and_parse_files(msg_info.str, files)) {
|
||||||
buf->type_ = TYPE_CONFIRM_UPDATE_LIST;
|
buf->type_ = TYPE_CONFIRM_UPDATE_LIST;
|
||||||
|
list_server_uuid_ = msg_info.uuid;
|
||||||
} else {
|
} else {
|
||||||
buf->type_ = TYPE_UNCONFIRM_UPDATE_LIST;
|
buf->type_ = TYPE_UNCONFIRM_UPDATE_LIST;
|
||||||
}
|
}
|
||||||
@ -1218,7 +1226,7 @@ void CClient::handle_frame(CFrameBuffer* buf)
|
|||||||
if (buf->type_ != TYPE_CONFIRM_UPDATE_LIST) {
|
if (buf->type_ != TYPE_CONFIRM_UPDATE_LIST) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
list_serve_id_ = buf->tid_;
|
list_server_id_ = buf->tid_;
|
||||||
TLOGD("Do Task From Remote {}.", buf->tid_);
|
TLOGD("Do Task From Remote {}.", buf->tid_);
|
||||||
if (update_list_th_.joinable()) {
|
if (update_list_th_.joinable()) {
|
||||||
update_list_th_.join();
|
update_list_th_.join();
|
||||||
|
@ -102,7 +102,8 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::string list_file_;
|
std::string list_file_;
|
||||||
std::string list_serve_id_;
|
std::string list_server_id_;
|
||||||
|
std::string list_server_uuid_;
|
||||||
std::thread update_list_th_;
|
std::thread update_list_th_;
|
||||||
std::string own_id_{};
|
std::string own_id_{};
|
||||||
std::string config_path_{};
|
std::string config_path_{};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user