!124 fix: 安装时可能出现的超时错误

Merge pull request !124 from Pluto/dev
This commit is contained in:
shenmo 2022-10-09 11:11:25 +00:00 committed by Gitee
commit 3feec88f7b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 7 additions and 7 deletions

View File

@ -151,7 +151,7 @@ void downloadlist::install(int t)
bool haveError = false; bool haveError = false;
bool notRoot = false; bool notRoot = false;
installer.waitForFinished(); installer.waitForFinished(-1); // 不设置超时
out = installer.readAllStandardOutput(); out = installer.readAllStandardOutput();
QStringList everyOut = out.split("\n"); QStringList everyOut = out.split("\n");
@ -169,7 +169,7 @@ void downloadlist::install(int t)
QProcess isInstall; QProcess isInstall;
isInstall.start("dpkg -s " + pkgName); isInstall.start("dpkg -s " + pkgName);
isInstall.waitForFinished(); isInstall.waitForFinished(180); // 默认超时 3 分钟
int error = QString::fromStdString(isInstall.readAllStandardError().toStdString()).length(); int error = QString::fromStdString(isInstall.readAllStandardError().toStdString()).length();
if(error == 0) if(error == 0)
{ {

View File

@ -1128,11 +1128,11 @@ void Widget::on_pushButton_uninstall_clicked()
QProcess uninstall; QProcess uninstall;
uninstall.start("pkexec", QStringList() << "apt" << "purge" << "-y" << pkgName.toLower()); uninstall.start("pkexec", QStringList() << "apt" << "purge" << "-y" << pkgName.toLower());
uninstall.waitForFinished(); uninstall.waitForFinished(-1); // 默认无限时长
QProcess check; QProcess check;
check.start("dpkg", QStringList() << "-s" << pkgName.toLower()); check.start("dpkg", QStringList() << "-s" << pkgName.toLower());
check.waitForFinished(); check.waitForFinished(180); // 默认超时 3 分钟
if (check.readAllStandardOutput().isEmpty()) if (check.readAllStandardOutput().isEmpty())
{ {

View File

@ -92,7 +92,7 @@ void SpkAppInfoLoaderThread::run()
QProcess isInstall; QProcess isInstall;
packagename = json["Pkgname"].toString(); packagename = json["Pkgname"].toString();
isInstall.start("dpkg -s " + json["Pkgname"].toString()); isInstall.start("dpkg -s " + json["Pkgname"].toString());
isInstall.waitForFinished(); isInstall.waitForFinished(180); // 默认超时 3 分钟
int error = QString::fromStdString(isInstall.readAllStandardError().toStdString()).length(); int error = QString::fromStdString(isInstall.readAllStandardError().toStdString()).length();
if(error == 0) if(error == 0)
{ {
@ -100,12 +100,12 @@ void SpkAppInfoLoaderThread::run()
QProcess isUpdate; QProcess isUpdate;
isUpdate.start("dpkg-query --showformat='${Version}' --show " + json["Pkgname"].toString()); isUpdate.start("dpkg-query --showformat='${Version}' --show " + json["Pkgname"].toString());
isUpdate.waitForFinished(); isUpdate.waitForFinished(180); // 默认超时 3 分钟
QString localVersion = isUpdate.readAllStandardOutput(); QString localVersion = isUpdate.readAllStandardOutput();
localVersion.replace("'", ""); localVersion.replace("'", "");
isUpdate.start("dpkg --compare-versions " + localVersion + " ge " + json["Version"].toString()); isUpdate.start("dpkg --compare-versions " + localVersion + " ge " + json["Version"].toString());
isUpdate.waitForFinished(); isUpdate.waitForFinished(180); // 默认超时 3 分钟
if(!isUpdate.exitCode()) if(!isUpdate.exitCode())
{ {
isUpdated = true; isUpdated = true;