From eae931f2ed21e82abb1461042251a8e9dcd370c6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 21 Aug 2019 03:43:51 -0400 Subject: [PATCH] [libcalamares] Ping only when accessibility is unknown - Restores exact functionality of previous version (noted by Kevin Kofler) - Short-circuit ping if the URL is bad. --- src/libcalamares/network/Manager.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libcalamares/network/Manager.cpp b/src/libcalamares/network/Manager.cpp index 716c93f6a..b0c068c6e 100644 --- a/src/libcalamares/network/Manager.cpp +++ b/src/libcalamares/network/Manager.cpp @@ -66,14 +66,14 @@ CalamaresUtils::Network::Manager::hasInternet() bool CalamaresUtils::Network::Manager::checkHasInternet() { - bool b = d->m_nam->networkAccessible() == QNetworkAccessManager::Accessible; + bool hasInternet = d->m_nam->networkAccessible() == QNetworkAccessManager::Accessible; - if ( !b && d->m_hasInternetUrl.isValid() ) + if ( !hasInternet && ( d->m_nam->networkAccessible() == QNetworkAccessManager::UnknownAccessibility ) ) { - b = synchronousPing( d->m_hasInternetUrl ); + hasInternet = synchronousPing( d->m_hasInternetUrl ); } - d->m_hasInternet = b; - return b; + d->m_hasInternet = hasInternet; + return hasInternet; } void @@ -85,6 +85,11 @@ CalamaresUtils::Network::Manager::setCheckHasInternetUrl( const QUrl& url ) bool CalamaresUtils::Network::Manager::synchronousPing( const QUrl& url ) { + if ( !url.isValid() ) + { + return false; + } + QNetworkRequest req = QNetworkRequest( url ); QNetworkReply* reply = d->m_nam->get( req ); QEventLoop loop;