Skip to content

Commit fcc7bc8

Browse files
committed
fix(compress): show tar filename during tar.7z compression
Display tar filename in progress when compressing tar.7z archives, improving user experience by showing meaningful progress information. 压缩tar.7z时显示tar文件名,提升用户体验。 Log: tar.7z压缩时提示tar文件名 PMS: BUG-356753 Influence: 压缩tar.7z格式时,进度提示显示tar文件名,用户可以看到正在处理的归档文件名称
1 parent 7d88329 commit fcc7bc8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

3rdparty/interface/archiveinterface/cliinterface.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,29 @@ void CliInterface::handleProgress(const QString &line)
963963

964964
emit signalCurFileName(fileName);
965965
}
966+
} else if (m_process && m_process->program().at(0).contains("tempScript")) {
967+
// 处理tar.7z进度
968+
// "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 7M + [Content]"
969+
// "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b274M 1 + [Content]"
970+
int pos = line.lastIndexOf(" + [Content]");
971+
if (pos > 1) {
972+
int mPos = line.lastIndexOf("M ");
973+
int bPos = line.lastIndexOf("\b", mPos);
974+
QString tempLine = line.left(mPos);
975+
// 已经压缩的文件大小
976+
qint64 compressedSize = tempLine.right(tempLine.size() - bPos - 1).toLongLong();
977+
// 计算文件大小计算百分比
978+
qint64 percentage = compressedSize * 1024 * 1024 * 100 / m_filesSize;
979+
980+
emit signalprogress(percentage);
981+
// tar.7z 无法获取正在压缩的单个文件名,但可以提示正在打包成 tar 文件
982+
// 发送 tar 文件名提示(去掉 .7z 后缀,显示正在打包的 tar 文件名)
983+
QString tarFileName = QFileInfo(m_strArchiveName).fileName();
984+
if (tarFileName.endsWith(".7z", Qt::CaseInsensitive)) {
985+
tarFileName = tarFileName.left(tarFileName.length() - 3);
986+
}
987+
emit signalCurFileName(tarFileName);
988+
}
966989
}
967990
}
968991

0 commit comments

Comments
 (0)