Skip to content

Commit 6a053bd

Browse files
pppanghu77deepin-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 7187fd9 commit 6a053bd

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/source/mainwindow.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,7 +2253,7 @@ void MainWindow::saveConfigWinState()
22532253
// 使用默认尺寸或之前保存的正常尺寸
22542254
QVariant tempWidth = m_pSettings->value(MAINWINDOW_WIDTH_NAME);
22552255
QVariant tempHeight = m_pSettings->value(MAINWINDOW_HEIGHT_NAME);
2256-
2256+
22572257
if (!tempWidth.isValid() || !tempHeight.isValid()) {
22582258
// 如果没有之前保存的尺寸,使用默认尺寸
22592259
m_pSettings->setValue(MAINWINDOW_WIDTH_NAME, MAINWINDOW_DEFAULTW);
@@ -2279,10 +2279,10 @@ void MainWindow::restoreConfigWinState()
22792279
// 获取保存的窗口状态
22802280
Qt::WindowState savedState = static_cast<Qt::WindowState>(
22812281
m_pSettings->value(MAINWINDOW_STATE_NAME, Qt::WindowNoState).toInt());
2282-
2282+
22832283
// 先设置正常尺寸
22842284
resize(getConfigWinSize());
2285-
2285+
22862286
// 然后应用状态
22872287
if (savedState == Qt::WindowMaximized) {
22882288
// 使用QTimer延迟执行,确保窗口完全初始化后再最大化
@@ -2498,12 +2498,22 @@ bool MainWindow::handleArguments_RightMenu(const QStringList &listParam)
24982498
//这里使用最后一个文件夹名进行压缩,防止特殊字符压缩不成功
24992499
QRegExp reg("^\s+|[\\:*\"'?<>|\r\n\t]");
25002500
if (strpath.mid(iIndex).indexOf(reg) != -1) {
2501-
QString compressor = strpath.split("=").last() + strSuffix;
2501+
QString folderName = strpath.split("=").last();
2502+
// 处理长文件夹名称,避免超出系统限制
2503+
if (folderName.length() + strSuffix.length() > FILE_TRUNCATION_LENGTH) {
2504+
folderName = folderName.left(FILE_TRUNCATION_LENGTH - strSuffix.length());
2505+
}
2506+
QString compressor = folderName + strSuffix;
25022507
if (compressor.indexOf(reg) != -1)
25032508
compressor.remove(reg);
25042509
strArchivePath += QDir::separator() + compressor;
25052510
} else {
2506-
strArchivePath += strpath.mid(iIndex) + strSuffix;
2511+
QString folderName = strpath.mid(iIndex + 1); // 去掉前面的分隔符
2512+
// 处理长文件夹名称,避免超出系统限制
2513+
if (folderName.length() + strSuffix.length() > FILE_TRUNCATION_LENGTH) {
2514+
folderName = folderName.left(FILE_TRUNCATION_LENGTH - strSuffix.length());
2515+
}
2516+
strArchivePath += QDir::separator() + folderName + strSuffix;
25072517
}
25082518
}
25092519

0 commit comments

Comments
 (0)