[gnome-software] Do not enable distro-upgrades when updates are disabled



commit 43040cff086494a12f385635c77ee47c2fa48b2c
Author: Richard Hughes <richard hughsie com>
Date:   Tue Dec 5 10:48:03 2017 +0000

    Do not enable distro-upgrades when updates are disabled
    
    This also fixes a big where the updates-changed event could get the update
    monitor to request the update list even if the GSetting is false.
    
    Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=790965

 data/org.gnome.software.gschema.xml |    4 ++--
 src/gs-update-monitor.c             |   16 ++++++++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/data/org.gnome.software.gschema.xml b/data/org.gnome.software.gschema.xml
index 1285b95..d1c498d 100644
--- a/data/org.gnome.software.gschema.xml
+++ b/data/org.gnome.software.gschema.xml
@@ -7,8 +7,8 @@
     </key>
     <key name="allow-updates" type="b">
       <default>true</default>
-      <summary>Whether to manage updates in GNOME Software</summary>
-      <description>If disabled, GNOME Software will hide the updates panel and not perform any automatic 
updates actions.</description>
+      <summary>Whether to manage updates and upgrades in GNOME Software</summary>
+      <description>If disabled, GNOME Software will hide the updates panel, not perform any automatic 
updates actions or prompt for upgrades.</description>
     </key>
     <key name="download-updates" type="b">
       <default>true</default>
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index 621885b..ee01d83 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -316,6 +316,13 @@ static void
 get_updates (GsUpdateMonitor *monitor)
 {
        g_autoptr(GsPluginJob) plugin_job = NULL;
+
+       /* disabled in gsettings or from a plugin */
+       if (!gs_plugin_loader_get_allow_updates (monitor->plugin_loader)) {
+               g_debug ("not getting updates as not enabled");
+               return;
+       }
+
        /* NOTE: this doesn't actually do any network access, instead it just
         * returns already downloaded-and-depsolved packages */
        g_debug ("Getting updates");
@@ -336,6 +343,12 @@ get_upgrades (GsUpdateMonitor *monitor)
 {
        g_autoptr(GsPluginJob) plugin_job = NULL;
 
+       /* disabled in gsettings or from a plugin */
+       if (!gs_plugin_loader_get_allow_updates (monitor->plugin_loader)) {
+               g_debug ("not getting upgrades as not enabled");
+               return;
+       }
+
        /* NOTE: this doesn't actually do any network access, it relies on the
         * AppStream data being up to date, either by the appstream-data
         * package being up-to-date, or the metadata being auto-downloaded */
@@ -381,8 +394,7 @@ refresh_cache_finished_cb (GObject *object,
                        g_warning ("failed to refresh the cache: %s", error->message);
                return;
        }
-       if (gs_plugin_loader_get_allow_updates (monitor->plugin_loader))
-               get_updates (monitor);
+       get_updates (monitor);
 }
 
 typedef enum {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]