Commit 869a902d authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

fwupd: remove unneeded downloads map

parent acce2ef6
......@@ -357,30 +357,9 @@ FwupdResource* FwupdBackend::createApp(FwupdDevice *device)
return app;
}
void FwupdBackend::saveFile(QNetworkReply *reply)
{
QString filename = this->m_downloadFile[reply->url()];
if (reply->error() == QNetworkReply::NoError)
{
QByteArray Data = reply->readAll();
QFile file(filename);
if (file.open(QIODevice::WriteOnly))
{
file.write(Data);
}
else
{
qWarning() << "Fwupd Error: Cannot Open File to write Data";
}
file.close();
delete reply;
}
}
bool FwupdBackend::downloadFile(const QUrl &uri,const QString &filename)
bool FwupdBackend::downloadFile(const QUrl &uri, const QString &filename)
{
QScopedPointer<QNetworkAccessManager> manager(new QNetworkAccessManager(this));
this->m_downloadFile.insert(uri,filename);
QEventLoop loop;
QTimer getTimer;
connect(&getTimer, &QTimer::timeout, &loop, &QEventLoop::quit);
......@@ -391,15 +370,18 @@ bool FwupdBackend::downloadFile(const QUrl &uri,const QString &filename)
if (!reply)
{
return false;
}
else if (QNetworkReply::NoError != reply->error() )
{
} else if (QNetworkReply::NoError != reply->error() ) {
qWarning() << "error fetching" << uri;
return false;
} else if (reply->error() == QNetworkReply::NoError) {
QFile file(filename);
if (file.open(QIODevice::WriteOnly)) {
file.write(reply->readAll());
} else {
qWarning() << "Fwupd Error: Cannot Open File to write Data" << filename;
}
}
else
{
saveFile(reply);
}
reply->deleteLater();
return true;
}
......
......@@ -100,14 +100,10 @@ public:
public Q_SLOTS:
void toggleFetching();
private Q_SLOTS:
void saveFile(QNetworkReply *reply);
private:
void populate();
QHash<QString, FwupdResource*> m_resources;
QMap<QUrl,QString> m_downloadFile;
StandardBackendUpdater* m_updater;
bool m_fetching;
int m_startElements;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment