up:基本验证逻辑完成。

This commit is contained in:
2025-11-06 23:12:13 +08:00
parent d92ab6c029
commit 648fca13c5
12 changed files with 62 additions and 19 deletions

View File

@@ -5,6 +5,8 @@ AccessModifierOffset: -4
ReflowComments: true
SpacesBeforeTrailingComments: 3
AllowShortFunctionsOnASingleLine: None
AllowShortEnumsOnASingleLine: false
AllowEnum
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true

View File

@@ -145,7 +145,8 @@
"qgraphicsdropshadoweffect": "cpp",
"qpushbutton": "cpp",
"qpainter": "cpp",
"qdialog": "cpp"
"qdialog": "cpp",
"quuid": "cpp"
},
"editor.tokenColorCustomizations": {
"textMateRules": [

View File

@@ -87,14 +87,19 @@ void ClientCore::handleAsk(QSharedPointer<FrameBuffer> frame)
InfoMsg msg = infoUnpack<InfoMsg>(frame->data);
// TODO: 处理询问请求
if (msg.command == STRMSG_AC_CHECK_FILE_EXIST) {
InfoMsg ans;
ans.command = STRMSG_AC_ANSWER_FILE_EXIST;
for (const auto& filePath : msg.list) {
if (!Util::FileExist(filePath)) {
ans.list.append(filePath);
msg.command = STRMSG_AC_ANSWER_FILE_EXIST;
for (auto& item : msg.mapData) {
if (item.mark == STRMSG_AC_UP) {
if (!Util::DirExist(item.key, true)) {
item.properD = static_cast<qint32>(FCS_DIR_NOT_EXIST);
}
} else {
if (!Util::FileExist(item.key)) {
item.properD = static_cast<qint32>(FCS_FILE_NOT_EXIST);
}
}
}
if (!Send<InfoMsg>(ans, FBT_MSGINFO_ANSWER, frame->fid)) {
if (!Send<InfoMsg>(msg, FBT_MSGINFO_ANSWER, frame->fid)) {
auto logMsg = tr("") + frame->fid + tr("返回检查文件存在性消息失败。");
qCritical() << logMsg;
return;

View File

@@ -10,7 +10,6 @@
#include "ClientCore.h"
constexpr int MAX_SEND_TASK = 10;
struct TransTask {
bool isUpload{false};
QString localId;
@@ -19,6 +18,9 @@ struct TransTask {
QString remoteId;
QString remotePath;
QString remoteUUID;
QString taskUUID;
FileCheckState localCheckState{FCS_NORMAL};
FileCheckState remoteCheckState{FCS_NORMAL};
};
enum class TaskState {

View File

@@ -310,6 +310,7 @@ void Compare::TransToLeft()
const QTableWidgetItem* itemF = ui->tableWidget->item(indexList[i].row(), 2);
const QTableWidgetItem* itemT = ui->tableWidget->item(indexList[i].row(), 1);
TransTask task;
task.taskUUID = Util::UUID();
task.isUpload = false;
task.localId = GlobalData::Ins()->GetLocalID();
task.localPath = itemT->text();
@@ -330,6 +331,7 @@ void Compare::TransToRight()
const QTableWidgetItem* itemF = ui->tableWidget->item(indexList[i].row(), 1);
const QTableWidgetItem* itemT = ui->tableWidget->item(indexList[i].row(), 2);
TransTask task;
task.taskUUID = Util::UUID();
task.isUpload = true;
task.localId = GlobalData::Ins()->GetLocalID();
task.localPath = Util::Join(itemF->text(), ui->tableWidget->item(indexList[i].row(), 0)->text());

View File

@@ -56,6 +56,7 @@ void CustomTableWidget::dropEvent(QDropEvent* event)
continue;
}
TransTask task;
task.taskUUID = Util::UUID();
task.isUpload = isRemote_;
task.localId = oidCall_();
task.remoteId = ridCall_();

View File

@@ -166,8 +166,8 @@ void CheckCondition::recvFrame(QSharedPointer<FrameBuffer> frame)
{
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
if (info.command == STRMSG_AC_ANSWER_FILE_EXIST) {
remoteNotExits_ = info.list;
qInfo() << tr("检查结束,远端不存在的文件数:") << remoteNotExits_.size();
infoMsg_ = info;
qInfo() << tr("检查结束......");
msg_ = info.command;
return;
}
@@ -192,10 +192,12 @@ void CheckCondition::run()
isAlreadyInter_ = false;
// 先检查本地文件是否存在
for (const auto& task : tasks_) {
for (auto& task : tasks_) {
if (task.isUpload && !Util::FileExist(task.localPath)) {
task.localCheckState = FCS_FILE_NOT_EXIST;
}
if (!task.isUpload && Util::FileExist(task.localPath)) {
if (!task.isUpload && !Util::DirExist(task.localPath, true)) {
task.localCheckState = FCS_DIR_NOT_EXIST;
}
}
@@ -203,7 +205,8 @@ void CheckCondition::run()
InfoMsg msg;
msg.command = STRMSG_AC_CHECK_FILE_EXIST;
for (const auto& task : tasks_) {
msg.list.push_back(task.remotePath);
msg.mapData[task.taskUUID].mark = task.isUpload ? STRMSG_AC_UP : STRMSG_AC_DOWN;
msg.mapData[task.taskUUID].key = task.remotePath;
}
auto f = clientCore_->GetBuffer(msg, FBT_MSGINFO_ASK, clientCore_->GetRemoteID());

View File

@@ -102,7 +102,7 @@ private:
bool isAlreadyInter_;
QVector<TransTask> tasks_;
ClientCore* clientCore_{};
QVector<QString> remoteNotExits_;
InfoMsg infoMsg_;
};
#endif // TRANSFORM_H

View File

@@ -59,6 +59,11 @@ public:
static QByteArray PackBuffer(const QSharedPointer<FrameBuffer>& frame);
};
enum FileCheckState {
FCS_NORMAL = 0,
FCS_DIR_NOT_EXIST,
FCS_FILE_NOT_EXIST
};
// 字符串标识
#define STRMSG_AC_CHECK_FILE_EXIST "requestCheckFileExist"
@@ -73,6 +78,8 @@ public:
#define STRMSG_AC_ANSWER_NEW_DIR "answerNewDir"
#define STRMSG_AC_ASK_FILEINFO "requestFileInfo"
#define STRMSG_AC_ANSWER_FILEINFO "answerFileInfo"
#define STRMSG_AC_UP "upAction"
#define STRMSG_AC_DOWN "downAction"
#define STRMSG_ST_FILEEXIT "fileExist"
#define STRMSG_ST_FILENOEXIT "fileNotExist"

View File

@@ -14,8 +14,8 @@ struct PropertyData {
QString properA;
QString properB;
QString properC;
QString properD;
QString properE;
qint32 properD;
qint32 properE;
};
struct InfoMsg {

View File

@@ -6,6 +6,7 @@
#include <QFileInfo>
#include <QMutex>
#include <QStandardPaths>
#include <QUuid>
#include <fversion.h>
#include <iostream>
#include <spdlog/fmt/bundled/color.h>
@@ -130,9 +131,27 @@ bool Util::FileExist(const QString& path)
return QFile::exists(path);
}
bool Util::DirExist(const QString& path)
bool Util::DirExist(const QString& path, bool isFilePath)
{
return QDir(path).exists();
if (path.isEmpty()) {
return false;
}
QString dirPath = path;
if (isFilePath) {
QFileInfo fileInfo(path);
dirPath = fileInfo.absolutePath();
} else {
QFileInfo dirInfo(path);
dirPath = dirInfo.absoluteFilePath();
}
QDir dir(dirPath);
return dir.exists();
}
QString Util::UUID()
{
return QUuid::createUuid().toString().remove("{").remove("}");
}
QString DirFileHelper::GetErr() const

View File

@@ -50,7 +50,8 @@ public:
static void ConsoleMsgHander(QtMsgType type, const QMessageLogContext& context, const QString& msg);
static QString GetVersion();
static bool FileExist(const QString& path);
static bool DirExist(const QString& path);
static bool DirExist(const QString& path, bool isFilePath);
static QString UUID();
};
class DirFileHelper : public QObject