chore:更新软件后,删除deb包

This commit is contained in:
2025-10-13 16:58:00 +08:00
parent 35f34dd469
commit b157f134d4

View File

@@ -369,11 +369,20 @@ void AppDelegate::startNextInstall() {
qDebug().noquote() << QString::fromLocal8Bit(err);
});
connect(m_installProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, [this, packageName, logFile](int exitCode, QProcess::ExitStatus status) {
this, [this, packageName, logFile, debPath](int exitCode, QProcess::ExitStatus status) {
if (logFile) logFile->close();
m_downloads[packageName].isInstalling = false;
if (exitCode == 0) {
m_downloads[packageName].isInstalled = true;
// 安装成功后删除deb包
if (QFile::exists(debPath)) {
if (QFile::remove(debPath)) {
qDebug() << "已删除deb包:" << debPath;
} else {
qWarning() << "删除deb包失败:" << debPath;
}
}
}
emit updateDisplay(packageName);
m_installProcess->deleteLater();
@@ -382,13 +391,23 @@ void AppDelegate::startNextInstall() {
startNextInstall();
});
} else {
connect(m_installProcess, &QProcess::readyReadStandardOutput, this, [this, packageName]() {
connect(m_installProcess, &QProcess::readyReadStandardOutput, this, [this, packageName, debPath]() {
QByteArray out = m_installProcess->readAllStandardOutput();
QString text = QString::fromLocal8Bit(out);
qDebug().noquote() << text;
if (text.contains(QStringLiteral("软件包已安装"))) {
m_downloads[packageName].isInstalling = false;
m_downloads[packageName].isInstalled = true;
// 安装成功后删除deb包
if (QFile::exists(debPath)) {
if (QFile::remove(debPath)) {
qDebug() << "已删除deb包:" << debPath;
} else {
qWarning() << "删除deb包失败:" << debPath;
}
}
emit updateDisplay(packageName);
}
});
@@ -397,7 +416,16 @@ void AppDelegate::startNextInstall() {
qDebug().noquote() << QString::fromLocal8Bit(err);
});
connect(m_installProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, [this, packageName](int /*exitCode*/, QProcess::ExitStatus /*status*/) {
this, [this, packageName, debPath](int exitCode, QProcess::ExitStatus /*status*/) {
// 如果通过退出码判断安装成功也删除deb包
if (exitCode == 0 && QFile::exists(debPath)) {
if (QFile::remove(debPath)) {
qDebug() << "已删除deb包:" << debPath;
} else {
qWarning() << "删除deb包失败:" << debPath;
}
}
emit updateDisplay(packageName);
m_installProcess->deleteLater();
m_installProcess = nullptr;