Skip to content

Commit

Permalink
fix: 仓库未更新时无法备份驱动
Browse files Browse the repository at this point in the history
修复仓库未更新时无法下载驱动进行备份

Log: 修复仓库未更新时无法下载驱动进行备份

https://pms.uniontech.com/bug-view-242971.html
  • Loading branch information
feeengli authored and deepin-bot[bot] committed Mar 6, 2024
1 parent a969e7a commit 8e43622
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,20 @@ bool ControlInterface::backupDeb(const QString &debpath)

bool ControlInterface::delDeb(const QString &debname)
{
if (!getUserAuthorPasswd()) {
return false;
}
if (!getUserAuthorPasswd()) {
return false;
}
return mp_drivermanager->delDeb(debname);
}

bool ControlInterface::aptUpdate()
{
if (!getUserAuthorPasswd()) {
return false;
}
return mp_drivermanager->aptUpdate();
}

#endif
bool ControlInterface::authorizedEnable(const QString &hclass, const QString &name, const QString &path, const QString &unique_id, bool enable_device, const QString strDriver)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public slots:
Q_SCRIPTABLE bool unInstallPrinter(const QString &vendor, const QString &model);
Q_SCRIPTABLE bool backupDeb(const QString &debpath); //debpath格式须是: “/tmp/xx/debname
Q_SCRIPTABLE bool delDeb(const QString &debname);
Q_SCRIPTABLE bool aptUpdate();

#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,22 @@ bool DriverManager::delDeb(const QString &debname)
return (!destdir.exists());
}

bool DriverManager::aptUpdate()
{
QProcess process;
/* connect(&process, &QProcess::readyReadStandardOutput, this, [&](){
QByteArray outArry = process.readAllStandardOutput();
QList<QString> lines = QString(outArry).split('\n', QString::SkipEmptyParts);
for (const QString &line : qAsConst(lines)) {
// qDebug() << line;
// error handling...
}
}); */
process.start("apt update");
process.waitForFinished(-1);
return true;
}

/**
* @brief DriverManager::backupDeb backup 驱动
* @param modulename 驱动deb模块名
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class DriverManager : public QObject
bool isDebValid(const QString &filePath);
bool backupDeb(const QString &debpath);
bool delDeb(const QString &debname);
bool aptUpdate();

private:
void initConnections();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ bool DBusDriverInterface::delDeb(const QString &debname)
return reply.value();
}

bool DBusDriverInterface::aptUpdate()
{
QDBusReply<bool> reply = mp_Iface->call("aptUpdate");

return reply.value();
}

DBusDriverInterface::DBusDriverInterface(QObject *parent)
: QObject(parent)
, mp_Iface(nullptr)
Expand Down
6 changes: 6 additions & 0 deletions deepin-devicemanager/src/DriverControl/DBusDriverInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ class DBusDriverInterface : public QObject
*/
bool delDeb(const QString &debname);

/**
* @brief aptUpdate apt update
* @return
*/
bool aptUpdate();

signals:
void processChange(qint32 value, QString details);
void processEnd(bool sucess, QString msg);
Expand Down
12 changes: 12 additions & 0 deletions deepin-devicemanager/src/DriverControl/DriverBackupThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// 备份临时路径
#define DB_PATH_TMP "/tmp/deepin-devicemanager"

static bool updateFlag = false;

DriverBackupThread::DriverBackupThread(QObject *parent)
: QThread(parent)
, mp_driverInfo(nullptr)
Expand Down Expand Up @@ -41,6 +43,16 @@ void DriverBackupThread::run()
return;
}

if(!updateFlag) {
bool ret = DBusDriverInterface::getInstance()->aptUpdate();
updateFlag = true;
if (!ret) {
emit backupProgressFinished(false);
qInfo() << "apt update failed.";
return;
}
}

QStringList options;
options << "-c" << "apt download " + debname + "=" + debversion;
QProcess process;
Expand Down

0 comments on commit 8e43622

Please sign in to comment.