up:文件校验功能进度更新。
This commit is contained in:
@@ -86,9 +86,9 @@ void ClientCore::handleAsk(QSharedPointer<FrameBuffer> frame)
|
|||||||
{
|
{
|
||||||
InfoMsg msg = infoUnpack<InfoMsg>(frame->data);
|
InfoMsg msg = infoUnpack<InfoMsg>(frame->data);
|
||||||
// TODO: 处理询问请求
|
// TODO: 处理询问请求
|
||||||
if (msg.command == STRMSG_REQUEST_CHECK_FILE_EXIST) {
|
if (msg.command == STRMSG_AC_CHECK_FILE_EXIST) {
|
||||||
InfoMsg ans;
|
InfoMsg ans;
|
||||||
ans.command = STRMSG_ANSWER_CHECK_FILE_EXIST;
|
ans.command = STRMSG_AC_ANSWER_FILE_EXIST;
|
||||||
for (const auto& filePath : msg.list) {
|
for (const auto& filePath : msg.list) {
|
||||||
if (!Util::FileExist(filePath)) {
|
if (!Util::FileExist(filePath)) {
|
||||||
ans.list.append(filePath);
|
ans.list.append(filePath);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ void FileTrans::ReqSendFile(const TransTask& task)
|
|||||||
sendTask_->state = TaskState::STATE_RUNNING;
|
sendTask_->state = TaskState::STATE_RUNNING;
|
||||||
// TODO: check if running...
|
// TODO: check if running...
|
||||||
if (sendTask_->file.isOpen()) {
|
if (sendTask_->file.isOpen()) {
|
||||||
qWarning() << QString(tr("file [%1] is already opened, will auto close.")).arg(sendTask_->file.fileName());
|
qWarning() << QString(tr("文件 [%1] 已经被打开,将会自动关闭。")).arg(sendTask_->file.fileName());
|
||||||
sendTask_->file.close();
|
sendTask_->file.close();
|
||||||
}
|
}
|
||||||
// start
|
// start
|
||||||
@@ -30,7 +30,7 @@ void FileTrans::ReqSendFile(const TransTask& task)
|
|||||||
|
|
||||||
sendTask_->file.setFileName(info.fromPath);
|
sendTask_->file.setFileName(info.fromPath);
|
||||||
if (!sendTask_->file.open(QIODevice::ReadOnly)) {
|
if (!sendTask_->file.open(QIODevice::ReadOnly)) {
|
||||||
qCritical() << QString(tr("open file [%1] failed.")).arg(info.fromPath);
|
qCritical() << QString(tr("打开 [%1] 失败。")).arg(info.fromPath);
|
||||||
sendTask_->state = TaskState::STATE_NONE;
|
sendTask_->state = TaskState::STATE_NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ void FileTrans::ReqSendFile(const TransTask& task)
|
|||||||
if (fileInfo.exists()) {
|
if (fileInfo.exists()) {
|
||||||
qint64 size = fileInfo.size();
|
qint64 size = fileInfo.size();
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
qCritical() << QString(tr("File [%1] size is 0, will not send.")).arg(info.fromPath);
|
qCritical() << QString(tr("文件 [%1] 尺寸为0不会进行发送。")).arg(info.fromPath);
|
||||||
sendTask_->file.close();
|
sendTask_->file.close();
|
||||||
sendTask_->state = TaskState::STATE_FINISH;
|
sendTask_->state = TaskState::STATE_FINISH;
|
||||||
return;
|
return;
|
||||||
@@ -47,14 +47,14 @@ void FileTrans::ReqSendFile(const TransTask& task)
|
|||||||
info.permissions = static_cast<quint32>(fileInfo.permissions());
|
info.permissions = static_cast<quint32>(fileInfo.permissions());
|
||||||
info.size = size;
|
info.size = size;
|
||||||
} else {
|
} else {
|
||||||
qCritical() << QString(tr("File [%1] not exit.")).arg(info.fromPath);
|
qCritical() << QString(tr("文件 [%1] 不存在。")).arg(info.fromPath);
|
||||||
sendTask_->file.close();
|
sendTask_->file.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto frame = clientCore_->GetBuffer(info, FBT_CLI_REQ_SEND, task.remoteId);
|
auto frame = clientCore_->GetBuffer(info, FBT_CLI_REQ_SEND, task.remoteId);
|
||||||
if (!ClientCore::syncInvoke(clientCore_, frame)) {
|
if (!ClientCore::syncInvoke(clientCore_, frame)) {
|
||||||
qCritical() << QString(tr("send req send failed: %1")).arg(info.msg);
|
qCritical() << QString(tr("返回发送请求失败:%1")).arg(info.msg);
|
||||||
sendTask_->state = TaskState::STATE_NONE;
|
sendTask_->state = TaskState::STATE_NONE;
|
||||||
sendTask_->file.close();
|
sendTask_->file.close();
|
||||||
return;
|
return;
|
||||||
@@ -78,13 +78,13 @@ void FileTrans::ReqDownFile(const TransTask& task)
|
|||||||
downTask_->totalSize = 0;
|
downTask_->totalSize = 0;
|
||||||
downTask_->file.setFileName(Util::Get2FilePath(task.remotePath, task.localPath));
|
downTask_->file.setFileName(Util::Get2FilePath(task.remotePath, task.localPath));
|
||||||
if (!downTask_->file.open(QIODevice::WriteOnly)) {
|
if (!downTask_->file.open(QIODevice::WriteOnly)) {
|
||||||
qCritical() << QString(tr("open file [%1] failed.")).arg(downTask_->file.fileName());
|
qCritical() << QString(tr("打开文件 [%1] 失败。")).arg(downTask_->file.fileName());
|
||||||
downTask_->state = TaskState::STATE_NONE;
|
downTask_->state = TaskState::STATE_NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto frame = clientCore_->GetBuffer(info, FBT_CLI_REQ_DOWN, task.remoteId);
|
auto frame = clientCore_->GetBuffer(info, FBT_CLI_REQ_DOWN, task.remoteId);
|
||||||
if (!ClientCore::syncInvoke(clientCore_, frame)) {
|
if (!ClientCore::syncInvoke(clientCore_, frame)) {
|
||||||
qCritical() << QString(tr("send req send failed: %1")).arg(info.msg);
|
qCritical() << QString(tr("返回发送请求失败:%1")).arg(info.msg);
|
||||||
downTask_->state = TaskState::STATE_NONE;
|
downTask_->state = TaskState::STATE_NONE;
|
||||||
downTask_->file.close();
|
downTask_->file.close();
|
||||||
return;
|
return;
|
||||||
@@ -151,13 +151,13 @@ void FileTrans::RegisterSignal()
|
|||||||
void FileTrans::fbtReqSend(QSharedPointer<FrameBuffer> frame)
|
void FileTrans::fbtReqSend(QSharedPointer<FrameBuffer> frame)
|
||||||
{
|
{
|
||||||
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
||||||
qInfo() << QString(tr("%1 req send: %2 to %3")).arg(frame->fid).arg(info.fromPath, info.toPath);
|
qInfo() << QString(tr("%1 请求发送 %2 到 %3")).arg(frame->fid).arg(info.fromPath, info.toPath);
|
||||||
|
|
||||||
// judge is same client's same file.
|
// judge is same client's same file.
|
||||||
|
|
||||||
// recv is single thread recv, judge idle
|
// recv is single thread recv, judge idle
|
||||||
if (downTask_->state == TaskState::STATE_RUNNING) {
|
if (downTask_->state == TaskState::STATE_RUNNING) {
|
||||||
info.msg = QString(tr("busy..."));
|
info.msg = QString(tr("繁忙......"));
|
||||||
auto f = clientCore_->GetBuffer(info, FBT_CLI_CANOT_SEND, frame->fid);
|
auto f = clientCore_->GetBuffer(info, FBT_CLI_CANOT_SEND, frame->fid);
|
||||||
ClientCore::syncInvoke(clientCore_, f);
|
ClientCore::syncInvoke(clientCore_, f);
|
||||||
return;
|
return;
|
||||||
@@ -167,11 +167,11 @@ void FileTrans::fbtReqSend(QSharedPointer<FrameBuffer> frame)
|
|||||||
auto newerPath = Util::Get2FilePath(info.fromPath, info.toPath);
|
auto newerPath = Util::Get2FilePath(info.fromPath, info.toPath);
|
||||||
downTask_->file.setFileName(newerPath);
|
downTask_->file.setFileName(newerPath);
|
||||||
if (!downTask_->file.open(QIODevice::WriteOnly)) {
|
if (!downTask_->file.open(QIODevice::WriteOnly)) {
|
||||||
info.msg = QString(tr("open file failed: %1")).arg(newerPath);
|
info.msg = QString(tr("打卡文件失败: %1")).arg(newerPath);
|
||||||
qCritical() << info.msg;
|
qCritical() << info.msg;
|
||||||
auto f = clientCore_->GetBuffer(info, FBT_CLI_CANOT_SEND, frame->fid);
|
auto f = clientCore_->GetBuffer(info, FBT_CLI_CANOT_SEND, frame->fid);
|
||||||
if (!ClientCore::syncInvoke(clientCore_, f)) {
|
if (!ClientCore::syncInvoke(clientCore_, f)) {
|
||||||
qCritical() << QString(tr("open recv file:%2 failed, and reply %2 failed.")).arg(info.msg, f->fid);
|
qCritical() << QString(tr("打开接收文件 %2 失败,回复 %2 失败。")).arg(info.msg, f->fid);
|
||||||
downTask_->file.close();
|
downTask_->file.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -182,11 +182,11 @@ void FileTrans::fbtReqSend(QSharedPointer<FrameBuffer> frame)
|
|||||||
downTask_->tranSize = 0;
|
downTask_->tranSize = 0;
|
||||||
downTask_->permission = info.permissions;
|
downTask_->permission = info.permissions;
|
||||||
|
|
||||||
info.msg = QString(tr("open recv file success: %1")).arg(newerPath);
|
info.msg = QString(tr("打开待接收文件成功:%1")).arg(newerPath);
|
||||||
qInfo() << info.msg;
|
qInfo() << info.msg;
|
||||||
auto f = clientCore_->GetBuffer(info, FBT_CLI_CAN_SEND, frame->fid);
|
auto f = clientCore_->GetBuffer(info, FBT_CLI_CAN_SEND, frame->fid);
|
||||||
if (!ClientCore::syncInvoke(clientCore_, f)) {
|
if (!ClientCore::syncInvoke(clientCore_, f)) {
|
||||||
qCritical() << QString(tr("open recv file:%2 success, but reply %2 failed.")).arg(info.msg, frame->fid);
|
qCritical() << QString(tr("打开接收文件 %1 成功, 但是回复 %2 失败。")).arg(info.msg, frame->fid);
|
||||||
downTask_->file.close();
|
downTask_->file.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ void FileTrans::fbtReqDown(QSharedPointer<FrameBuffer> frame)
|
|||||||
auto doTask = QSharedPointer<DoTransTask>::create();
|
auto doTask = QSharedPointer<DoTransTask>::create();
|
||||||
doTask->file.setFileName(info.fromPath);
|
doTask->file.setFileName(info.fromPath);
|
||||||
if (!doTask->file.open(QIODevice::ReadOnly)) {
|
if (!doTask->file.open(QIODevice::ReadOnly)) {
|
||||||
qCritical() << QString(tr("open file failed: %1")).arg(info.fromPath);
|
qCritical() << QString(tr("打开文件失败:%1")).arg(info.fromPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ void FileTrans::fbtReqDown(QSharedPointer<FrameBuffer> frame)
|
|||||||
info.permissions = static_cast<quint32>(fileInfo.permissions());
|
info.permissions = static_cast<quint32>(fileInfo.permissions());
|
||||||
info.size = size;
|
info.size = size;
|
||||||
} else {
|
} else {
|
||||||
qCritical() << QString(tr("File [%1] not exit.")).arg(info.fromPath);
|
qCritical() << QString(tr("文件 [%1] 不存在。")).arg(info.fromPath);
|
||||||
doTask->file.close();
|
doTask->file.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -223,7 +223,7 @@ void FileTrans::fbtReqDown(QSharedPointer<FrameBuffer> frame)
|
|||||||
// reply fileinfo
|
// reply fileinfo
|
||||||
auto f = clientCore_->GetBuffer(info, FBT_CLI_FILE_INFO, frame->fid);
|
auto f = clientCore_->GetBuffer(info, FBT_CLI_FILE_INFO, frame->fid);
|
||||||
if (!ClientCore::syncInvoke(clientCore_, f)) {
|
if (!ClientCore::syncInvoke(clientCore_, f)) {
|
||||||
qCritical() << QString(tr("send file %1 info failed.")).arg(info.fromPath);
|
qCritical() << QString(tr("发送 %1 信息失败。")).arg(info.fromPath);
|
||||||
doTask->file.close();
|
doTask->file.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -240,11 +240,11 @@ void FileTrans::fbtTransDone(QSharedPointer<FrameBuffer> frame)
|
|||||||
downTask_->file.setPermissions(static_cast<QFileDevice::Permissions>(downTask_->permission));
|
downTask_->file.setPermissions(static_cast<QFileDevice::Permissions>(downTask_->permission));
|
||||||
downTask_->file.close();
|
downTask_->file.close();
|
||||||
downTask_->state = TaskState::STATE_FINISH;
|
downTask_->state = TaskState::STATE_FINISH;
|
||||||
info.msg = QString(tr("recv file:%1 success.")).arg(downTask_->file.fileName());
|
info.msg = QString(tr("接收文件:%1 成功。")).arg(downTask_->file.fileName());
|
||||||
qInfo() << info.msg;
|
qInfo() << info.msg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qCritical() << QString(tr("recv file:%1 done sigal, but file not opened.")).arg(info.msg);
|
qCritical() << QString(tr("成功收到了信号:%1 但是文件未打开。")).arg(info.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the other party indicates that can download, ready to receive the file.
|
// the other party indicates that can download, ready to receive the file.
|
||||||
@@ -261,7 +261,7 @@ void FileTrans::fbtCanDown(QSharedPointer<FrameBuffer> frame)
|
|||||||
void FileTrans::fbtCanotDown(QSharedPointer<FrameBuffer> frame)
|
void FileTrans::fbtCanotDown(QSharedPointer<FrameBuffer> frame)
|
||||||
{
|
{
|
||||||
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
||||||
qCritical() << QString(tr("request send file:%1 failed. reason:%2")).arg(info.fromPath, info.msg);
|
qCritical() << QString(tr("请求发送文件 %1 失败,原因:%2")).arg(info.fromPath, info.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileTrans::fbtFileBuffer(QSharedPointer<FrameBuffer> frame)
|
void FileTrans::fbtFileBuffer(QSharedPointer<FrameBuffer> frame)
|
||||||
@@ -285,7 +285,7 @@ void FileTrans::fbtFileBuffer(QSharedPointer<FrameBuffer> frame)
|
|||||||
void FileTrans::fbtFileInfo(QSharedPointer<FrameBuffer> frame)
|
void FileTrans::fbtFileInfo(QSharedPointer<FrameBuffer> frame)
|
||||||
{
|
{
|
||||||
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
||||||
qInfo() << QString(tr("prepare downfile's size is:%1, perm:%2")).arg(info.size).arg(info.permissions);
|
qInfo() << QString(tr("准备接收文件的大小:%1,权限:%2")).arg(info.size).arg(info.permissions);
|
||||||
downTask_->totalSize = info.size;
|
downTask_->totalSize = info.size;
|
||||||
downTask_->tranSize = 0;
|
downTask_->tranSize = 0;
|
||||||
downTask_->permission = info.permissions;
|
downTask_->permission = info.permissions;
|
||||||
@@ -294,7 +294,7 @@ void FileTrans::fbtFileInfo(QSharedPointer<FrameBuffer> frame)
|
|||||||
void FileTrans::fbtCanotSend(QSharedPointer<FrameBuffer> frame)
|
void FileTrans::fbtCanotSend(QSharedPointer<FrameBuffer> frame)
|
||||||
{
|
{
|
||||||
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
||||||
qCritical() << QString(tr("request file:%1 failed. reason:%2")).arg(info.fromPath, info.msg);
|
qCritical() << QString(tr("请求文件 %1 失败,原因:%2")).arg(info.fromPath, info.msg);
|
||||||
if (sendTask_->file.isOpen()) {
|
if (sendTask_->file.isOpen()) {
|
||||||
sendTask_->file.close();
|
sendTask_->file.close();
|
||||||
}
|
}
|
||||||
@@ -303,13 +303,13 @@ void FileTrans::fbtCanotSend(QSharedPointer<FrameBuffer> frame)
|
|||||||
void FileTrans::fbtCanSend(QSharedPointer<FrameBuffer> frame)
|
void FileTrans::fbtCanSend(QSharedPointer<FrameBuffer> frame)
|
||||||
{
|
{
|
||||||
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
||||||
qInfo() << QString(tr("Can Send start trans file:%1 to %2")).arg(info.fromPath, frame->fid);
|
qInfo() << QString(tr("开始发送 %1 到 %2")).arg(info.fromPath, frame->fid);
|
||||||
SendFile(sendTask_);
|
SendFile(sendTask_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileTrans::fbtTransFailed(QSharedPointer<FrameBuffer> frame)
|
void FileTrans::fbtTransFailed(QSharedPointer<FrameBuffer> frame)
|
||||||
{
|
{
|
||||||
qCritical() << QString(tr("trans file:%1 failed.")).arg(downTask_->file.fileName());
|
qCritical() << QString(tr("传输文件 %1 失败。")).arg(downTask_->file.fileName());
|
||||||
if (downTask_->file.isOpen()) {
|
if (downTask_->file.isOpen()) {
|
||||||
downTask_->file.close();
|
downTask_->file.close();
|
||||||
}
|
}
|
||||||
@@ -319,11 +319,11 @@ void FileTrans::fbtTransFailed(QSharedPointer<FrameBuffer> frame)
|
|||||||
void FileTrans::fbtInterrupt(QSharedPointer<FrameBuffer> frame)
|
void FileTrans::fbtInterrupt(QSharedPointer<FrameBuffer> frame)
|
||||||
{
|
{
|
||||||
if (downTask_->state == TaskState::STATE_RUNNING) {
|
if (downTask_->state == TaskState::STATE_RUNNING) {
|
||||||
qWarning() << QString(tr("trans file:%1 interrupt.")).arg(downTask_->file.fileName());
|
qWarning() << QString(tr("传输文件 %1 中断。")).arg(downTask_->file.fileName());
|
||||||
downTask_->state = TaskState::STATE_NONE;
|
downTask_->state = TaskState::STATE_NONE;
|
||||||
}
|
}
|
||||||
if (sendTask_->state == TaskState::STATE_RUNNING) {
|
if (sendTask_->state == TaskState::STATE_RUNNING) {
|
||||||
qWarning() << QString(tr("trans file:%1 interrupt.")).arg(sendTask_->file.fileName());
|
qWarning() << QString(tr("传输文件 %1 中断。")).arg(sendTask_->file.fileName());
|
||||||
sendTask_->state = TaskState::STATE_NONE;
|
sendTask_->state = TaskState::STATE_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,8 +173,8 @@ std::string Connecter::getCurClient()
|
|||||||
void Connecter::InitControl()
|
void Connecter::InitControl()
|
||||||
{
|
{
|
||||||
ui->edOwnID->setReadOnly(true);
|
ui->edOwnID->setReadOnly(true);
|
||||||
ui->label->setStyleSheet("color: blue;");
|
ui->label->setStyleSheet("color: green;");
|
||||||
ui->edOwnID->setStyleSheet("color: blue;");
|
ui->edOwnID->setStyleSheet("color: green;");
|
||||||
|
|
||||||
ui->btnDisconnect->setEnabled(false);
|
ui->btnDisconnect->setEnabled(false);
|
||||||
ui->comboBox->setEditable(true);
|
ui->comboBox->setEditable(true);
|
||||||
@@ -191,7 +191,7 @@ void Connecter::InitControl()
|
|||||||
connect(ui->btnDisconnect, &QPushButton::clicked, this, &Connecter::Disconnect);
|
connect(ui->btnDisconnect, &QPushButton::clicked, this, &Connecter::Disconnect);
|
||||||
|
|
||||||
menu_ = new QMenu(this);
|
menu_ = new QMenu(this);
|
||||||
QAction* acUseThis = menu_->addAction(tr("UseThis"));
|
QAction* acUseThis = menu_->addAction(tr("与此客户端通信"));
|
||||||
connect(acUseThis, &QAction::triggered, this, [this]() {
|
connect(acUseThis, &QAction::triggered, this, [this]() {
|
||||||
auto index = ui->listView->currentIndex();
|
auto index = ui->listView->currentIndex();
|
||||||
if (!index.isValid()) {
|
if (!index.isValid()) {
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ void CheckCondition::SetTasks(const QVector<TransTask>& tasks)
|
|||||||
void CheckCondition::recvFrame(QSharedPointer<FrameBuffer> frame)
|
void CheckCondition::recvFrame(QSharedPointer<FrameBuffer> frame)
|
||||||
{
|
{
|
||||||
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
||||||
if (info.command == STRMSG_ANSWER_CHECK_FILE_EXIST) {
|
if (info.command == STRMSG_AC_ANSWER_FILE_EXIST) {
|
||||||
remoteNotExits_ = info.list;
|
remoteNotExits_ = info.list;
|
||||||
qInfo() << tr("检查结束,远端不存在的文件数:") << remoteNotExits_.size();
|
qInfo() << tr("检查结束,远端不存在的文件数:") << remoteNotExits_.size();
|
||||||
msg_ = info.command;
|
msg_ = info.command;
|
||||||
@@ -187,9 +187,6 @@ void CheckCondition::interrupCheck()
|
|||||||
void CheckCondition::run()
|
void CheckCondition::run()
|
||||||
{
|
{
|
||||||
qInfo() << tr("开始文件校验......");
|
qInfo() << tr("开始文件校验......");
|
||||||
|
|
||||||
resultMsgMap_.clear();
|
|
||||||
checkRet_.clear();
|
|
||||||
isRun_ = true;
|
isRun_ = true;
|
||||||
msg_.clear();
|
msg_.clear();
|
||||||
isAlreadyInter_ = false;
|
isAlreadyInter_ = false;
|
||||||
@@ -197,22 +194,14 @@ void CheckCondition::run()
|
|||||||
// 先检查本地文件是否存在
|
// 先检查本地文件是否存在
|
||||||
for (const auto& task : tasks_) {
|
for (const auto& task : tasks_) {
|
||||||
if (task.isUpload && !Util::FileExist(task.localPath)) {
|
if (task.isUpload && !Util::FileExist(task.localPath)) {
|
||||||
resultMsgMap_[CCR_CHECK_LOCAL_NOT_EXIT].push_back(task.localPath);
|
|
||||||
if (!checkRet_.contains(CCR_CHECK_LOCAL_NOT_EXIT)) {
|
|
||||||
checkRet_.push_back(CCR_CHECK_LOCAL_NOT_EXIT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!task.isUpload && Util::FileExist(task.localPath)) {
|
if (!task.isUpload && Util::FileExist(task.localPath)) {
|
||||||
resultMsgMap_[CCR_CHECK_LOCAL_EXIT].push_back(task.localPath);
|
|
||||||
if (!checkRet_.contains(CCR_CHECK_LOCAL_EXIT)) {
|
|
||||||
checkRet_.push_back(CCR_CHECK_LOCAL_EXIT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 再检查远程文件是否存在
|
// 再检查远程文件是否存在
|
||||||
InfoMsg msg;
|
InfoMsg msg;
|
||||||
msg.command = STRMSG_REQUEST_CHECK_FILE_EXIST;
|
msg.command = STRMSG_AC_CHECK_FILE_EXIST;
|
||||||
for (const auto& task : tasks_) {
|
for (const auto& task : tasks_) {
|
||||||
msg.list.push_back(task.remotePath);
|
msg.list.push_back(task.remotePath);
|
||||||
}
|
}
|
||||||
@@ -220,10 +209,6 @@ void CheckCondition::run()
|
|||||||
auto f = clientCore_->GetBuffer(msg, FBT_MSGINFO_ASK, clientCore_->GetRemoteID());
|
auto f = clientCore_->GetBuffer(msg, FBT_MSGINFO_ASK, clientCore_->GetRemoteID());
|
||||||
if (!ClientCore::syncInvoke(clientCore_, f)) {
|
if (!ClientCore::syncInvoke(clientCore_, f)) {
|
||||||
auto errMsg = tr("检查远程文件存在性数据发送失败。");
|
auto errMsg = tr("检查远程文件存在性数据发送失败。");
|
||||||
if (!checkRet_.contains(CCR_CHECK_FAILED)) {
|
|
||||||
checkRet_.push_back(CCR_CHECK_FAILED);
|
|
||||||
resultMsgMap_[CCR_CHECK_FAILED].push_back(errMsg);
|
|
||||||
}
|
|
||||||
emit sigCheckOver();
|
emit sigCheckOver();
|
||||||
qCritical() << errMsg;
|
qCritical() << errMsg;
|
||||||
return;
|
return;
|
||||||
@@ -233,16 +218,6 @@ void CheckCondition::run()
|
|||||||
if (msg_.isEmpty()) {
|
if (msg_.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (msg_ != STRMSG_ANSWER_CHECK_FILE_EXIST) {
|
|
||||||
if (!checkRet_.contains(CCR_CHECK_FAILED)) {
|
|
||||||
checkRet_.push_back(CCR_CHECK_FAILED);
|
|
||||||
resultMsgMap_[CCR_CHECK_FAILED].push_back(msg_);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!checkRet_.contains(CCR_CHECK_PASSED)) {
|
|
||||||
checkRet_.push_back(CCR_CHECK_PASSED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
isAlreadyInter_ = true;
|
isAlreadyInter_ = true;
|
||||||
|
|||||||
@@ -75,17 +75,6 @@ private:
|
|||||||
TransForm* tf_;
|
TransForm* tf_;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CondCheckResult {
|
|
||||||
CCR_NO_CHECK = 0,
|
|
||||||
CCR_CHECK_PASSED,
|
|
||||||
CCR_CHECK_FAILED,
|
|
||||||
CCR_CHECK_INTERRUPT,
|
|
||||||
CCR_CHECK_LOCAL_EXIT,
|
|
||||||
CCR_CHECK_REMOTE_EXIT,
|
|
||||||
CCR_CHECK_LOCAL_NOT_EXIT,
|
|
||||||
CCR_CHECK_REMOTE_NOT_EXIT
|
|
||||||
};
|
|
||||||
|
|
||||||
class CheckCondition : public QThread
|
class CheckCondition : public QThread
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -114,8 +103,6 @@ private:
|
|||||||
QVector<TransTask> tasks_;
|
QVector<TransTask> tasks_;
|
||||||
ClientCore* clientCore_{};
|
ClientCore* clientCore_{};
|
||||||
QVector<QString> remoteNotExits_;
|
QVector<QString> remoteNotExits_;
|
||||||
QVector<CondCheckResult> checkRet_;
|
|
||||||
std::unordered_map<CondCheckResult, QVector<QString>> resultMsgMap_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRANSFORM_H
|
#endif // TRANSFORM_H
|
||||||
@@ -41,10 +41,6 @@ enum FrameBufferType : uint16_t {
|
|||||||
FBT_MSGINFO_ANSWER
|
FBT_MSGINFO_ANSWER
|
||||||
};
|
};
|
||||||
|
|
||||||
// 字符串标识
|
|
||||||
#define STRMSG_REQUEST_CHECK_FILE_EXIST "requestCheckFileExist"
|
|
||||||
#define STRMSG_ANSWER_CHECK_FILE_EXIST "answerCheckFileExist"
|
|
||||||
|
|
||||||
struct FrameBuffer {
|
struct FrameBuffer {
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
QString fid;
|
QString fid;
|
||||||
@@ -63,4 +59,24 @@ public:
|
|||||||
static QByteArray PackBuffer(const QSharedPointer<FrameBuffer>& frame);
|
static QByteArray PackBuffer(const QSharedPointer<FrameBuffer>& frame);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROTOCOL_H
|
|
||||||
|
// 字符串标识
|
||||||
|
#define STRMSG_AC_CHECK_FILE_EXIST "requestCheckFileExist"
|
||||||
|
#define STRMSG_AC_ANSWER_FILE_EXIST "answerCheckFileExist"
|
||||||
|
#define STRMSG_AC_DEL_FILE "requestDelFile"
|
||||||
|
#define STRMSG_AC_ANSWER_DEL_FILE "answerDelFile"
|
||||||
|
#define STRMSG_AC_DEL_DIR "requestDelDir"
|
||||||
|
#define STRMSG_AC_ANSWER_DEL_DIR "answerDelDir"
|
||||||
|
#define STRMSG_AC_RENAME_FILEDIR "requestRenameFileDir"
|
||||||
|
#define STRMSG_AC_ANSWER_FILEDIR "answerRenameFileDir"
|
||||||
|
#define STRMSG_AC_NEW_DIR "requestNewDir"
|
||||||
|
#define STRMSG_AC_ANSWER_NEW_DIR "answerNewDir"
|
||||||
|
#define STRMSG_AC_ASK_FILEINFO "requestFileInfo"
|
||||||
|
#define STRMSG_AC_ANSWER_FILEINFO "answerFileInfo"
|
||||||
|
|
||||||
|
#define STRMSG_ST_FILEEXIT "fileExist"
|
||||||
|
#define STRMSG_ST_FILENOEXIT "fileNotExist"
|
||||||
|
#define STRMSG_ST_DIREXIT "dirExist"
|
||||||
|
#define STRMSG_ST_DIRNOEXIT "dirNotExist"
|
||||||
|
|
||||||
|
#endif // PROTOCOL_H
|
||||||
@@ -6,6 +6,17 @@
|
|||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
struct PropertyData {
|
||||||
|
QString key;
|
||||||
|
QString mark;
|
||||||
|
QString properA;
|
||||||
|
QString properB;
|
||||||
|
QString properC;
|
||||||
|
QString properD;
|
||||||
|
QString properE;
|
||||||
|
};
|
||||||
|
|
||||||
struct InfoMsg {
|
struct InfoMsg {
|
||||||
qint32 mark{};
|
qint32 mark{};
|
||||||
@@ -16,6 +27,7 @@ struct InfoMsg {
|
|||||||
quint64 size{};
|
quint64 size{};
|
||||||
quint32 permissions{};
|
quint32 permissions{};
|
||||||
QVector<QString> list;
|
QVector<QString> list;
|
||||||
|
QMap<QString, PropertyData> mapData;
|
||||||
|
|
||||||
void serialize(QDataStream& data) const
|
void serialize(QDataStream& data) const
|
||||||
{
|
{
|
||||||
@@ -24,6 +36,10 @@ struct InfoMsg {
|
|||||||
for (const auto& item : list) {
|
for (const auto& item : list) {
|
||||||
data << item;
|
data << item;
|
||||||
}
|
}
|
||||||
|
data << mapData.size();
|
||||||
|
for (const auto& item : mapData) {
|
||||||
|
data << item.key << item.mark << item.properA << item.properB << item.properC << item.properD << item.properE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void deserialize(QDataStream& data)
|
void deserialize(QDataStream& data)
|
||||||
@@ -35,6 +51,14 @@ struct InfoMsg {
|
|||||||
for (auto& item : list) {
|
for (auto& item : list) {
|
||||||
data >> item;
|
data >> item;
|
||||||
}
|
}
|
||||||
|
qint32 mapSize;
|
||||||
|
data >> mapSize;
|
||||||
|
data >> mapSize;
|
||||||
|
for (int i = 0; i < mapSize; ++i) {
|
||||||
|
PropertyData prop;
|
||||||
|
data >> prop.key >> prop.mark >> prop.properA >> prop.properB >> prop.properC >> prop.properD >> prop.properE;
|
||||||
|
mapData.insert(prop.key, prop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
QDataStream& operator<<(QDataStream& data, const InfoMsg& info);
|
QDataStream& operator<<(QDataStream& data, const InfoMsg& info);
|
||||||
|
|||||||
Reference in New Issue
Block a user