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 ReflowComments: true
SpacesBeforeTrailingComments: 3 SpacesBeforeTrailingComments: 3
AllowShortFunctionsOnASingleLine: None AllowShortFunctionsOnASingleLine: None
AllowShortEnumsOnASingleLine: false
AllowEnum
BreakBeforeBraces: Custom BreakBeforeBraces: Custom
BraceWrapping: BraceWrapping:
AfterFunction: true AfterFunction: true

View File

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

View File

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

View File

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

View File

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

View File

@@ -166,8 +166,8 @@ void CheckCondition::recvFrame(QSharedPointer<FrameBuffer> frame)
{ {
InfoMsg info = infoUnpack<InfoMsg>(frame->data); InfoMsg info = infoUnpack<InfoMsg>(frame->data);
if (info.command == STRMSG_AC_ANSWER_FILE_EXIST) { if (info.command == STRMSG_AC_ANSWER_FILE_EXIST) {
remoteNotExits_ = info.list; infoMsg_ = info;
qInfo() << tr("检查结束,远端不存在的文件数:") << remoteNotExits_.size(); qInfo() << tr("检查结束......");
msg_ = info.command; msg_ = info.command;
return; return;
} }
@@ -192,10 +192,12 @@ void CheckCondition::run()
isAlreadyInter_ = false; isAlreadyInter_ = false;
// 先检查本地文件是否存在 // 先检查本地文件是否存在
for (const auto& task : tasks_) { for (auto& task : tasks_) {
if (task.isUpload && !Util::FileExist(task.localPath)) { 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; InfoMsg msg;
msg.command = STRMSG_AC_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.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()); auto f = clientCore_->GetBuffer(msg, FBT_MSGINFO_ASK, clientCore_->GetRemoteID());

View File

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

View File

@@ -59,6 +59,11 @@ public:
static QByteArray PackBuffer(const QSharedPointer<FrameBuffer>& frame); 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" #define STRMSG_AC_CHECK_FILE_EXIST "requestCheckFileExist"
@@ -73,6 +78,8 @@ public:
#define STRMSG_AC_ANSWER_NEW_DIR "answerNewDir" #define STRMSG_AC_ANSWER_NEW_DIR "answerNewDir"
#define STRMSG_AC_ASK_FILEINFO "requestFileInfo" #define STRMSG_AC_ASK_FILEINFO "requestFileInfo"
#define STRMSG_AC_ANSWER_FILEINFO "answerFileInfo" #define STRMSG_AC_ANSWER_FILEINFO "answerFileInfo"
#define STRMSG_AC_UP "upAction"
#define STRMSG_AC_DOWN "downAction"
#define STRMSG_ST_FILEEXIT "fileExist" #define STRMSG_ST_FILEEXIT "fileExist"
#define STRMSG_ST_FILENOEXIT "fileNotExist" #define STRMSG_ST_FILENOEXIT "fileNotExist"

View File

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

View File

@@ -6,6 +6,7 @@
#include <QFileInfo> #include <QFileInfo>
#include <QMutex> #include <QMutex>
#include <QStandardPaths> #include <QStandardPaths>
#include <QUuid>
#include <fversion.h> #include <fversion.h>
#include <iostream> #include <iostream>
#include <spdlog/fmt/bundled/color.h> #include <spdlog/fmt/bundled/color.h>
@@ -130,9 +131,27 @@ bool Util::FileExist(const QString& path)
return QFile::exists(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 QString DirFileHelper::GetErr() const

View File

@@ -50,7 +50,8 @@ public:
static void ConsoleMsgHander(QtMsgType type, const QMessageLogContext& context, const QString& msg); static void ConsoleMsgHander(QtMsgType type, const QMessageLogContext& context, const QString& msg);
static QString GetVersion(); static QString GetVersion();
static bool FileExist(const QString& path); 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 class DirFileHelper : public QObject