Commit 01c49d35 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

notifier: delay fetching updates a few seconds

This way we don't hog the system as it's starting
parent 299ae55c
......@@ -40,25 +40,24 @@ static void installationChanged(GFileMonitor *monitor, GFile *child, GFile *othe
return;
}
notifier->checkUpdates();
notifier->recheckSystemUpdateNeeded();
}
FlatpakNotifier::FlatpakNotifier(QObject* parent)
: BackendNotifierModule(parent)
, m_cancellable(g_cancellable_new())
{
checkUpdates();
QTimer *dailyCheck = new QTimer(this);
dailyCheck->setInterval(24 * 60 * 60 * 1000); //refresh at least once every day
connect(dailyCheck, &QTimer::timeout, this, &FlatpakNotifier::checkUpdates);
connect(dailyCheck, &QTimer::timeout, this, &FlatpakNotifier::recheckSystemUpdateNeeded);
}
FlatpakNotifier::Installation::~Installation()
{
g_object_unref(m_monitor);
g_object_unref(m_installation);
if (m_monitor)
g_object_unref(m_monitor);
if (m_installation)
g_object_unref(m_installation);
}
FlatpakNotifier::~FlatpakNotifier()
......@@ -67,11 +66,6 @@ FlatpakNotifier::~FlatpakNotifier()
}
void FlatpakNotifier::recheckSystemUpdateNeeded()
{
checkUpdates();
}
void FlatpakNotifier::checkUpdates()
{
g_autoptr(GError) error = nullptr;
......
......@@ -41,11 +41,8 @@ public:
void recheckSystemUpdateNeeded() override;
bool needsReboot() const override { return false; }
public Q_SLOTS:
void checkUpdates();
void onFetchUpdatesFinished(FlatpakInstallation *flatpakInstallation, GPtrArray *updates);
private:
void onFetchUpdatesFinished(FlatpakInstallation *flatpakInstallation, GPtrArray *updates);
void loadRemoteUpdates(FlatpakInstallation *flatpakInstallation);
bool setupFlatpakInstallations(GError **error);
......
......@@ -44,12 +44,7 @@ PackageKitNotifier::PackageKitNotifier(QObject* parent)
, m_securityUpdates(0)
, m_normalUpdates(0)
{
if (PackageKit::Daemon::global()->isRunning()) {
recheckSystemUpdateNeeded();
}
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::networkStateChanged, this, &PackageKitNotifier::recheckSystemUpdateNeeded);
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::updatesChanged, this, &PackageKitNotifier::recheckSystemUpdateNeeded);
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::isRunningChanged, this, &PackageKitNotifier::recheckSystemUpdateNeeded);
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::transactionListChanged, this, &PackageKitNotifier::transactionListChanged);
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::restartScheduled, this, &PackageKitNotifier::nowNeedsReboot);
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::changed, this, [this]{
......@@ -153,6 +148,14 @@ void PackageKitNotifier::checkOfflineUpdates()
void PackageKitNotifier::recheckSystemUpdateNeeded()
{
static bool first = true;
if (first) {
//PKQt will emit these signals when it starts (bug?) and would trigger the system recheck before we've ever checked at all
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::networkStateChanged, this, &PackageKitNotifier::recheckSystemUpdateNeeded);
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::isRunningChanged, this, &PackageKitNotifier::recheckSystemUpdateNeeded);
first = false;
}
if (PackageKit::Daemon::global()->offline()->updateTriggered())
return;
......
......@@ -59,6 +59,9 @@ DiscoverNotifier::DiscoverNotifier(QObject * parent)
updateStatusNotifier();
connect(m_manager, &QNetworkConfigurationManager::onlineStateChanged, this, &DiscoverNotifier::stateChanged);
//Only fetch updates after the system is comfortably booted
QTimer::singleShot(10000, this, &DiscoverNotifier::recheckSystemUpdateNeeded);
}
DiscoverNotifier::~DiscoverNotifier() = default;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment