[users] Use right check on writing hostname

- !failed() also means "didn't write the file because it already
  exists", which is sometimes acceptable -- but not here.
  Use the more-strict bool() conversion, which is only when
  the file was actually written.
This commit is contained in:
Adriaan de Groot 2020-02-24 12:44:50 +01:00
parent 862b7e34df
commit 4621937477

View file

@ -61,9 +61,8 @@ SetHostNameJob::prettyStatusMessage() const
STATICTEST bool
setFileHostname( const QString& hostname )
{
return !( CalamaresUtils::System::instance()
->createTargetFile( QStringLiteral( "/etc/hostname" ), ( hostname + '\n' ).toUtf8() )
.failed() );
return CalamaresUtils::System::instance()->createTargetFile( QStringLiteral( "/etc/hostname" ),
( hostname + '\n' ).toUtf8() );
}
STATICTEST bool
@ -78,9 +77,8 @@ ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
)";
return !( CalamaresUtils::System::instance()
->createTargetFile( QStringLiteral( "/etc/hosts" ), QString( etc_hosts ).arg( hostname ).toUtf8() )
.failed() );
return CalamaresUtils::System::instance()->createTargetFile( QStringLiteral( "/etc/hosts" ),
QString( etc_hosts ).arg( hostname ).toUtf8() );
}
STATICTEST bool