Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复追加文件为软连接问题 #191

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion 3rdparty/interface/archiveinterface/cliinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ PluginFinishType CliInterface::addFiles(const QList<FileEntry> &files, const Com
// 压缩目标路径
const QString destinationPath = (options.strDestination == QString()) ? QString() : options.strDestination;
qInfo() << "Adding" << files.count() << "file(s) to destination:" << destinationPath;
bool isLink = true;

if (!destinationPath.isEmpty()) { // 向压缩包非第一层文件里面追加压缩
m_extractTempDir.reset(new QTemporaryDir());
Expand All @@ -326,6 +327,7 @@ PluginFinishType CliInterface::addFiles(const QList<FileEntry> &files, const Com
// 待压缩文件的文件名(临时路径全路径)
const QString newFilePath = absoluteDestinationPath + QFileInfo(file.strFullPath).fileName();

isLink = (isLink && QFileInfo(filePath).isSymLink());
// 在临时路径创建待压缩文件的链接
if (QFile::link(filePath, newFilePath)) {
qInfo() << "Symlink's created:" << filePath << newFilePath;
Expand Down Expand Up @@ -442,7 +444,18 @@ PluginFinishType CliInterface::addFiles(const QList<FileEntry> &files, const Com
ret = false;
}
} else {
ret = runProcess(m_cliProps->property("addProgram").toString(), arguments);
QString processName = m_cliProps->property("addProgram").toString();
if(processName == "7z" && !destinationPath.isEmpty()) {
if(!isLink) {
for(int i = 0; i < arguments.count(); i++) {
if(arguments.at(i) == QStringLiteral("-snl")) {
arguments.replace(i, QStringLiteral("-l"));
break;
}
}
}
}
ret = runProcess(processName, arguments);
}

if (ret && !temp_archiveName.isEmpty()) {
Expand Down
Loading