AssetDownloader: Provide network errors and SSL errors
Network errors and SSL errors are provided as invokable methods. The end user can collect the errors after download is finished. Task-number: QTBUG-136035 Pick-to: 6.8 Change-Id: Ic8bd9b84d331752c096998683b44b85be3cd6b10 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> (cherry picked from commit 124f05bd10c1ce2a5104394712fae54c0659fccb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
fd608b6a6b
commit
9842c84f36
@ -48,6 +48,8 @@ public:
|
||||
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
||||
QUrl m_offlineAssetsFilePath;
|
||||
QUrl m_downloadBase;
|
||||
QStringList m_networkErrors;
|
||||
QStringList m_sslErrors;
|
||||
|
||||
void setLocalDownloadDir(const QDir &dir)
|
||||
{
|
||||
@ -80,6 +82,16 @@ public:
|
||||
query, [this](qint64 bytesReceived, qint64 totalBytes) {
|
||||
updateProgress((totalBytes > 0) ? 100.0 * bytesReceived / totalBytes : 0, 100);
|
||||
});
|
||||
QObject::connect(reply, &QNetworkReply::errorOccurred, query, [this, reply] {
|
||||
m_networkErrors << reply->errorString();
|
||||
});
|
||||
#if QT_CONFIG(ssl)
|
||||
QObject::connect(reply, &QNetworkReply::sslErrors,
|
||||
query, [this](const QList<QSslError> &sslErrors) {
|
||||
for (const QSslError &sslError : sslErrors)
|
||||
m_sslErrors << sslError.errorString();
|
||||
});
|
||||
#endif
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -262,6 +274,16 @@ QUrl AssetDownloader::localDownloadDir() const
|
||||
return QUrl::fromLocalFile(d->m_localDownloadDir.absolutePath());
|
||||
}
|
||||
|
||||
QStringList AssetDownloader::networkErrors() const
|
||||
{
|
||||
return d->m_networkErrors;
|
||||
}
|
||||
|
||||
QStringList AssetDownloader::sslErrors() const
|
||||
{
|
||||
return d->m_sslErrors;
|
||||
}
|
||||
|
||||
static void precheckLocalFile(const QUrl &url)
|
||||
{
|
||||
if (url.isEmpty())
|
||||
@ -385,6 +407,8 @@ void AssetDownloader::start()
|
||||
}
|
||||
storage->tempDir = d->m_temporaryDir->path();
|
||||
d->setLocalDownloadDir(baseLocalDir(d->m_preferredLocalDownloadDir));
|
||||
d->m_networkErrors.clear();
|
||||
d->m_sslErrors.clear();
|
||||
precheckLocalFile(resolvedUrl(d->m_offlineAssetsFilePath));
|
||||
return SetupResult::Continue;
|
||||
};
|
||||
|
@ -86,6 +86,9 @@ public:
|
||||
|
||||
QUrl localDownloadDir() const;
|
||||
|
||||
Q_INVOKABLE QStringList networkErrors() const;
|
||||
Q_INVOKABLE QStringList sslErrors() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void start();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user