add: dir not and zero file size not trans and set recent ip to front.

This commit is contained in:
2025-06-29 00:36:10 +08:00
parent 07cd9b8a51
commit 2b87eb917a
4 changed files with 34 additions and 7 deletions

View File

@@ -40,6 +40,12 @@ void FileTrans::ReqSendFile(const TransTask& task)
QFileInfo fileInfo(info.fromPath); QFileInfo fileInfo(info.fromPath);
if (fileInfo.exists()) { if (fileInfo.exists()) {
qint64 size = fileInfo.size(); qint64 size = fileInfo.size();
if (size == 0) {
qCritical() << QString(tr("File [%1] size is 0, will not send.")).arg(info.fromPath);
sendTask_->file.close();
sendTask_->state = TaskState::STATE_FINISH;
return;
}
info.permissions = static_cast<quint32>(fileInfo.permissions()); info.permissions = static_cast<quint32>(fileInfo.permissions());
info.size = size; info.size = size;
} else { } else {

View File

@@ -41,12 +41,18 @@ void CustomTableWidget::dropEvent(QDropEvent* event)
QByteArray encoded = event->mimeData()->data("application/x-qabstractitemmodeldatalist"); QByteArray encoded = event->mimeData()->data("application/x-qabstractitemmodeldatalist");
QDataStream stream(&encoded, QIODevice::ReadOnly); QDataStream stream(&encoded, QIODevice::ReadOnly);
QStringList parseData;
QVector<TransTask> tasks; QVector<TransTask> tasks;
while (!stream.atEnd()) { while (!stream.atEnd()) {
int row, col; int row, col;
QMap<int, QVariant> roleData; QMap<int, QVariant> roleData;
stream >> row >> col >> roleData; stream >> row >> col >> roleData;
if (col != 1) { parseData.append(roleData[Qt::DisplayRole].toString());
}
for (int i = 0; i < (parseData.size() / 5); ++i) {
if (parseData[i * 5 + 3] != "File") {
qDebug() << QString(tr("Not Handle %1")).arg(parseData[i * 5 + 1]);
continue; continue;
} }
TransTask task; TransTask task;
@@ -55,10 +61,10 @@ void CustomTableWidget::dropEvent(QDropEvent* event)
task.remoteId = ridCall_(); task.remoteId = ridCall_();
if (isRemote_) { if (isRemote_) {
task.remotePath = GlobalData::Ins()->GetRemoteRoot(); task.remotePath = GlobalData::Ins()->GetRemoteRoot();
task.localPath = Util::Join(GlobalData::Ins()->GetLocalRoot(), roleData[Qt::DisplayRole].toString()); task.localPath = Util::Join(GlobalData::Ins()->GetLocalRoot(), parseData[i * 5 + 1]);
} else { } else {
task.localPath = GlobalData::Ins()->GetLocalRoot(); task.localPath = GlobalData::Ins()->GetLocalRoot();
task.remotePath = Util::Join(GlobalData::Ins()->GetRemoteRoot(), roleData[Qt::DisplayRole].toString()); task.remotePath = Util::Join(GlobalData::Ins()->GetRemoteRoot(), parseData[i * 5 + 1]);
} }
tasks.push_back(task); tasks.push_back(task);
} }

View File

@@ -27,10 +27,27 @@ bool FrelayConfig::SaveIpPort(const QString& ipPort)
vec = j["connections"].get<CgConVec>(); vec = j["connections"].get<CgConVec>();
} }
auto MoveIpToFront = [](CgConVec& vec, const QString& ipPort) {
auto it =
std::find_if(vec.begin(), vec.end(), [&ipPort](const CgConnection& conn) { return conn.ip == ipPort.toStdString(); });
if (it != vec.end()) {
std::rotate(vec.begin(), it, it + 1);
}
};
auto saveConfig = [this, &p](const CgConVec& vec) {
json j;
j["connections"] = vec;
std::ofstream ofs(p);
ofs << std::setw(4) << j << std::endl;
};
bool exist = false; bool exist = false;
for (const auto& v : vec) { for (const auto& v : vec) {
if (v.ip == ipPort.toStdString()) { if (v.ip == ipPort.toStdString()) {
exist = true; exist = true;
MoveIpToFront(vec, ipPort);
saveConfig(vec);
break; break;
} }
} }
@@ -44,9 +61,7 @@ bool FrelayConfig::SaveIpPort(const QString& ipPort)
vec.pop_back(); vec.pop_back();
} }
j["connections"] = vec; saveConfig(vec);
std::ofstream ofs(p);
ofs << std::setw(4) << j << std::endl;
return true; return true;
} }

View File

@@ -15,7 +15,7 @@
| 17 | 问题 | 服务端主动踢出的客户端,主动重连假链接,不可用无反应。 | | 0.1 | 0.2 | | 17 | 问题 | 服务端主动踢出的客户端,主动重连假链接,不可用无反应。 | | 0.1 | 0.2 |
| 16 | 优化 | 传输完成后接收端要刷新一次。 | | 0.1 | | | 16 | 优化 | 传输完成后接收端要刷新一次。 | | 0.1 | |
| 15 | 问题 | 拖动文件夹到对方,应当不处理,并日志提示。 | | 0.1 | | | 15 | 问题 | 拖动文件夹到对方,应当不处理,并日志提示。 | | 0.1 | |
| 14 | 功能 | 文件浏览部分添加右键复制全路径功能。 | | 0.1 | | | 14 | 功能 | 文件浏览部分添加右键复制全路径功能。 | | 0.1 | 0.2 |
| 13 | 功能 | IP端口部分要添加可选择历史。 | | 0.1 | 0.2 | | 13 | 功能 | IP端口部分要添加可选择历史。 | | 0.1 | 0.2 |
| 12 | 功能 | 对照传输前要先校验文件存在性。 | | 0.1 | | | 12 | 功能 | 对照传输前要先校验文件存在性。 | | 0.1 | |
| 11 | 问题 | 断连后当前远端ID要清除。 | | 0.1 | 0.2 | | 11 | 问题 | 断连后当前远端ID要清除。 | | 0.1 | 0.2 |