[gnome-software] Set a reasonable cache age for system upgrades



commit 6bf49d507385ca1aedbc17df4ee9f514f295e267
Author: Kalev Lember <klember redhat com>
Date:   Mon Jul 11 11:45:07 2016 +0200

    Set a reasonable cache age for system upgrades
    
    Previously we would use G_MAXUINT for all system upgrade operations
    which means to never refresh any metadata once we have _anything_
    downloaded. This broke pretty horribly because Fedora tends to put out
    new metadata every day together with deleting old rpms from mirrors.
    
    Instead, this changes it so that for background cache operations we
    download new system upgrade metadata every week, and once the user
    interactively clicks "Download" we download it again if it's older than
    a day.
    
    This should ensure that we have metadata that has a chance of working
    and referencing rpms that are actually available on mirrors.

 src/plugins/gs-plugin-packagekit-refine.c  |    5 +++++
 src/plugins/gs-plugin-packagekit-upgrade.c |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index a53caa1..f5b4402 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -737,6 +737,7 @@ gs_plugin_packagekit_refine_distro_upgrade (GsPlugin *plugin,
        ProgressData data;
        g_autoptr(PkResults) results = NULL;
        g_autoptr(GsAppList) list = NULL;
+       guint cache_age_save;
 
        data.app = app;
        data.plugin = plugin;
@@ -744,6 +745,8 @@ gs_plugin_packagekit_refine_distro_upgrade (GsPlugin *plugin,
        data.profile_id = NULL;
 
        /* ask PK to simulate upgrading the system */
+       cache_age_save = pk_client_get_cache_age (priv->client);
+       pk_client_set_cache_age (priv->client, 60 * 60 * 24 * 7); /* once per week */
        results = pk_client_upgrade_system (priv->client,
                                            pk_bitfield_from_enums (PK_TRANSACTION_FLAG_ENUM_SIMULATE, -1),
                                            gs_app_get_version (app),
@@ -751,6 +754,8 @@ gs_plugin_packagekit_refine_distro_upgrade (GsPlugin *plugin,
                                            cancellable,
                                            gs_plugin_packagekit_progress_cb, &data,
                                            error);
+       pk_client_set_cache_age (priv->client, cache_age_save);
+
        if (!gs_plugin_packagekit_results_valid (results, error))
                return FALSE;
        list = gs_app_list_new ();
diff --git a/src/plugins/gs-plugin-packagekit-upgrade.c b/src/plugins/gs-plugin-packagekit-upgrade.c
index 1d01ade..255e584 100644
--- a/src/plugins/gs-plugin-packagekit-upgrade.c
+++ b/src/plugins/gs-plugin-packagekit-upgrade.c
@@ -39,7 +39,7 @@ gs_plugin_initialize (GsPlugin *plugin)
        priv->task = pk_task_new ();
        pk_task_set_only_download (priv->task, TRUE);
        pk_client_set_background (PK_CLIENT (priv->task), TRUE);
-       pk_client_set_cache_age (PK_CLIENT (priv->task), G_MAXUINT);
+       pk_client_set_cache_age (PK_CLIENT (priv->task), 60 * 60 * 24);
        pk_client_set_interactive (PK_CLIENT (priv->task), FALSE);
 }
 


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