mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 19:05:46 -05:00
[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.
This commit is contained in:
parent
e065008631
commit
eae931f2ed
1 changed files with 10 additions and 5 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue