[users] Restore error-checking to set-hostname code

- Use the new CreationResult code for compact results
This commit is contained in:
Adriaan de Groot 2020-02-14 13:27:49 +01:00
parent f6526f7d9f
commit 90f79b0692

View File

@ -72,16 +72,13 @@ SetHostNameJob::exec()
return Calamares::JobResult::error( tr( "Internal Error" ) ); return Calamares::JobResult::error( tr( "Internal Error" ) );
} }
CalamaresUtils::System::instance()->createTargetFile( QStringLiteral( "/etc/hostname" ), if ( CalamaresUtils::System::instance()
( m_hostname + '\n' ).toUtf8() ); ->createTargetFile( QStringLiteral( "/etc/hostname" ), ( m_hostname + '\n' ).toUtf8() )
.failed() )
#if 0
if ( !hostfile.open( QFile::WriteOnly ) )
{ {
cError() << "Can't write to hostname file"; cError() << "Can't write to hostname file";
return Calamares::JobResult::error( tr( "Cannot write hostname to target system" ) ); return Calamares::JobResult::error( tr( "Cannot write hostname to target system" ) );
} }
#endif
// The actual hostname gets substituted in at %1 // The actual hostname gets substituted in at %1
static const char etc_hosts[] = R"(# Host addresses static const char etc_hosts[] = R"(# Host addresses
@ -92,16 +89,13 @@ ff02::1 ip6-allnodes
ff02::2 ip6-allrouters ff02::2 ip6-allrouters
)"; )";
CalamaresUtils::System::instance()->createTargetFile( QStringLiteral( "/etc/hosts" ), if ( CalamaresUtils::System::instance()
QString( etc_hosts ).arg( m_hostname ).toUtf8() ); ->createTargetFile( QStringLiteral( "/etc/hosts" ), QString( etc_hosts ).arg( m_hostname ).toUtf8() )
.failed() )
#if 0
if ( !hostsfile.open( QFile::WriteOnly ) )
{ {
cError() << "Can't write to hosts file"; cError() << "Can't write to hosts file";
return Calamares::JobResult::error( tr( "Cannot write hostname to target system" ) ); return Calamares::JobResult::error( tr( "Cannot write hostname to target system" ) );
} }
#endif
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
} }