over:文件存在性校验功能完成。

This commit is contained in:
2025-11-08 21:51:42 +08:00
parent f8bbf02e04
commit d209d64061
7 changed files with 83 additions and 30 deletions

View File

@@ -210,8 +210,12 @@ void CheckCondition::run()
if (task.isUpload && !Util::FileExist(task.localPath)) {
task.localCheckState = FCS_FILE_NOT_EXIST;
}
if (!task.isUpload && !Util::DirExist(task.localPath, true)) {
task.localCheckState = FCS_DIR_NOT_EXIST;
if (!task.isUpload) {
if (!Util::DirExist(task.localPath, false)) {
task.localCheckState = FCS_DIR_NOT_EXIST;
} else if (Util::FileExist(task.localPath)) {
task.localCheckState = FCS_FILE_EXIST;
}
}
}
@@ -222,7 +226,8 @@ void CheckCondition::run()
for (auto& task : tasks_) {
msg.mapData[task.taskUUID].uuid = task.taskUUID;
msg.mapData[task.taskUUID].command = task.isUpload ? STRMSG_AC_UP : STRMSG_AC_DOWN;
msg.mapData[task.taskUUID].path = task.remotePath;
msg.mapData[task.taskUUID].localPath = task.localPath;
msg.mapData[task.taskUUID].remotePath = task.remotePath;
}
auto f = clientCore_->GetBuffer(msg, FBT_MSGINFO_ASK, clientCore_->GetRemoteID());

View File

@@ -7,9 +7,9 @@
#include <QSplitter>
#include <QVBoxLayout>
#include <fversion.h>
#include "Control/Common.h"
#include "./ui_frelayGUI.h"
#include "Control/Common.h"
#include "Control/LogControl.h"
static LogPrint* logPrint = nullptr;
@@ -171,46 +171,70 @@ void frelayGUI::HandleTask(const QVector<TransTask>& tasks)
bool frelayGUI::CheckTaskResult(QVector<TransTask>& tasks)
{
bool isAccept = false;
bool isAutoCreateDirR = false;
bool isAutoRecoverR = false;
bool isAutoCreateDirL = false;
bool isAutoRecoverL = false;
for (auto& task : tasks) {
if (task.localCheckState == FCS_NORMAL && task.remoteCheckState == FCS_NORMAL) {
continue;
}
if (task.isUpload) {
if (task.localCheckState != FCS_NORMAL) {
if (task.localCheckState == FCS_FILE_NOT_EXIST) {
QMessageBox::information(this, tr("文件校验"), tr("本地文件校验失败,请检查文件是否存在:") + task.localPath);
return false;
}
if (task.remoteCheckState != FCS_NORMAL && !isAccept) {
if (task.remoteCheckState == FCS_DIR_NOT_EXIST && !isAutoCreateDirR) {
auto msg = tr("远端不存在文件夹") + task.remotePath + ",需要自动创建吗?";
auto ret =Common::GetAcceptThree(this, "操作确认", msg);
auto ret = Common::GetAcceptThree(this, "操作确认", msg);
if (ret == 0) {
continue;
}
else if (ret == 1) {
isAccept = true;
} else if (ret == 1) {
isAutoCreateDirR = true;
continue;
} else {
return false;
}
else {
}
if (task.remoteCheckState == FCS_FILE_EXIST && !isAutoRecoverR) {
auto msg = tr("远端已存在文件") + Util::Get2FilePath(task.localPath, task.remotePath) + ",需要覆盖吗?";
auto ret = Common::GetAcceptThree(this, "操作警告", msg);
if (ret == 0) {
continue;
} else if (ret == 1) {
isAutoRecoverR = true;
continue;
} else {
return false;
}
}
} else {
if (task.localCheckState != FCS_NORMAL) {
if (task.localCheckState == FCS_DIR_NOT_EXIST && !isAutoCreateDirL) {
auto msg = tr("本地不存在文件夹") + task.localPath + ",需要自动创建吗?";
auto ret =Common::GetAcceptThree(this, "操作确认", msg);
auto ret = Common::GetAcceptThree(this, "操作确认", msg);
if (ret == 0) {
continue;
}
else if (ret == 1) {
isAccept = true;
} else if (ret == 1) {
isAutoCreateDirL = true;
continue;
}
else {
} else {
return false;
}
}
if (task.remoteCheckState != FCS_NORMAL) {
if (task.localCheckState == FCS_FILE_EXIST && !isAutoRecoverL) {
auto msg = tr("本地已经存在文件") + Util::Get2FilePath(task.remotePath, task.localPath) + ",需要覆盖吗?";
auto ret = Common::GetAcceptThree(this, "操作警告", msg);
if (ret == 0) {
continue;
} else if (ret == 1) {
isAutoRecoverL = true;
continue;
} else {
return false;
}
}
if (task.remoteCheckState != FCS_FILE_EXIST) {
QMessageBox::information(this, tr("文件校验"), tr("远端文件校验失败,请检查文件是否存在:") + task.remotePath);
return false;
}