Skip to content

Commit 6fa837f

Browse files
GongHeng2017deepin-bot[bot]
authored andcommitted
Fix: Improve folder name handling in archive path construction
-- Updated the logic for constructing the archive path to handle long folder names, ensuring they do not exceed system limits. This includes trimming folder names when necessary and improving the overall robustness of the path handling. Log: Improve folder name handling in archive path construction Bug: https://pms.uniontech.com/bug-view-326399.html
1 parent c5fe5dc commit 6fa837f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/source/mainwindow.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,12 +2678,22 @@ bool MainWindow::handleArguments_RightMenu(const QStringList &listParam)
26782678
//这里使用最后一个文件夹名进行压缩,防止特殊字符压缩不成功
26792679
REG_EXP reg("^\s+|[\\:*\"'?<>|\r\n\t]");
26802680
if (strpath.mid(iIndex).indexOf(reg) != -1) {
2681-
QString compressor = strpath.split("=").last() + strSuffix;
2681+
QString folderName = strpath.split("=").last();
2682+
// 处理长文件夹名称,避免超出系统限制
2683+
if (folderName.length() + strSuffix.length() > FILE_TRUNCATION_LENGTH) {
2684+
folderName = folderName.left(FILE_TRUNCATION_LENGTH - strSuffix.length());
2685+
}
2686+
QString compressor = folderName + strSuffix;
26822687
if (compressor.indexOf(reg) != -1)
26832688
compressor.remove(reg);
26842689
strArchivePath += QDir::separator() + compressor;
26852690
} else {
2686-
strArchivePath += strpath.mid(iIndex) + strSuffix;
2691+
QString folderName = strpath.mid(iIndex + 1); // 去掉前面的分隔符
2692+
// 处理长文件夹名称,避免超出系统限制
2693+
if (folderName.length() + strSuffix.length() > FILE_TRUNCATION_LENGTH) {
2694+
folderName = folderName.left(FILE_TRUNCATION_LENGTH - strSuffix.length());
2695+
}
2696+
strArchivePath += QDir::separator() + folderName + strSuffix;
26872697
}
26882698
}
26892699

0 commit comments

Comments
 (0)