[locale] Call timedatectl only when needed

- When testing and running not-as-root, only call the timedatectl
   when the settings actually change; this reduces the number of
   times kauth pops up.
This commit is contained in:
Adriaan de Groot 2019-01-07 15:16:37 +01:00
parent dc06de58d8
commit e52f0318fe

View File

@ -484,19 +484,22 @@ LocalePage::prettyLCLocale( const QString& lcLocale ) const
void void
LocalePage::updateGlobalStorage() LocalePage::updateGlobalStorage()
{ {
auto *gs = Calamares::JobQueue::instance()->globalStorage();
LocaleGlobal::Location location = m_tzWidget->getCurrentLocation(); LocaleGlobal::Location location = m_tzWidget->getCurrentLocation();
Calamares::JobQueue::instance()->globalStorage() bool locationChanged = ( location.region != gs->value( "locationRegion" ) ) ||
->insert( "locationRegion", location.region ); ( location.zone != gs->value( "locationZone" ) );
Calamares::JobQueue::instance()->globalStorage()
->insert( "locationZone", location.zone ); gs->insert( "locationRegion", location.region );
gs->insert( "locationZone", location.zone );
const QString bcp47 = m_selectedLocaleConfiguration.toBcp47(); const QString bcp47 = m_selectedLocaleConfiguration.toBcp47();
Calamares::JobQueue::instance()->globalStorage()->insert( "locale", bcp47 ); gs->insert( "locale", bcp47 );
// If we're in chroot mode (normal install mode), then we immediately set the // If we're in chroot mode (normal install mode), then we immediately set the
// timezone on the live system. When debugging timezones, don't bother. // timezone on the live system. When debugging timezones, don't bother.
#ifndef DEBUG_TIMEZONES #ifndef DEBUG_TIMEZONES
if ( Calamares::Settings::instance()->doChroot() ) if ( locationChanged && Calamares::Settings::instance()->doChroot() )
{ {
QProcess::execute( "timedatectl", // depends on systemd QProcess::execute( "timedatectl", // depends on systemd
{ "set-timezone", { "set-timezone",