[gnome-software/gnome-3-20] Invalidate the upgrade if the update list is changed
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-20] Invalidate the upgrade if the update list is changed
- Date: Thu, 26 May 2016 14:27:41 +0000 (UTC)
commit 22d4da94e526d7c207c4eb531d46acd6d8ef6513
Author: Richard Hughes <richard hughsie com>
Date: Thu May 26 15:20:21 2016 +0100
Invalidate the upgrade if the update list is changed
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1336459
src/gs-shell-updates.c | 40 +++++++++++++++++++++++++++++
src/plugins/gs-plugin-packagekit-refine.c | 11 ++++++-
src/plugins/gs-plugin-packagekit.c | 14 +++++-----
3 files changed, 56 insertions(+), 9 deletions(-)
---
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index e7df579..d74fe23 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -1164,6 +1164,29 @@ gs_shell_updates_upgrade_help_cb (GsUpgradeBanner *upgrade_banner,
g_warning ("failed to open %s: %s", uri, error->message);
}
+static void
+gs_shell_updates_invalidate_downloaded_upgrade (GsShellUpdates *self)
+{
+ GsApp *app;
+ app = gs_upgrade_banner_get_app (GS_UPGRADE_BANNER (self->upgrade_banner));
+ if (app == NULL)
+ return;
+ if (gs_app_get_state (app) != AS_APP_STATE_UPDATABLE)
+ return;
+ gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
+ g_debug ("resetting %s to AVAILABLE as the updates have changed",
+ gs_app_get_id (app));
+}
+
+static void
+gs_shell_updates_changed_cb (GsPluginLoader *plugin_loader,
+ GsShellUpdates *self)
+{
+ /* if we do a live update and the upgrade is waiting to be deployed
+ * then make sure all new packages are downloaded */
+ gs_shell_updates_invalidate_downloaded_upgrade (self);
+}
+
/**
* gs_shell_updates_status_changed_cb:
**/
@@ -1173,6 +1196,20 @@ gs_shell_updates_status_changed_cb (GsPluginLoader *plugin_loader,
GsPluginStatus status,
GsShellUpdates *self)
{
+ switch (status) {
+ case GS_PLUGIN_STATUS_INSTALLING:
+ case GS_PLUGIN_STATUS_REMOVING:
+ if (gs_app_get_kind (app) != AS_APP_KIND_OS_UPGRADE &&
+ gs_app_get_id (app) != NULL) {
+ /* if we do a install or remove then make sure all new
+ * packages are downloaded */
+ gs_shell_updates_invalidate_downloaded_upgrade (self);
+ }
+ break;
+ default:
+ break;
+ }
+
self->last_status = status;
gs_shell_updates_update_ui_state (self);
}
@@ -1228,6 +1265,9 @@ gs_shell_updates_setup (GsShellUpdates *self,
g_signal_connect (self->plugin_loader, "status-changed",
G_CALLBACK (gs_shell_updates_status_changed_cb),
self);
+ g_signal_connect (self->plugin_loader, "updates-changed",
+ G_CALLBACK (gs_shell_updates_changed_cb),
+ self);
self->builder = g_object_ref (builder);
self->cancellable = g_object_ref (cancellable);
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index e85916a..1edeb72 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -108,6 +108,7 @@ gs_plugin_destroy (GsPlugin *plugin)
typedef struct {
+ GsApp *app;
GsPlugin *plugin;
AsProfileTask *ptask;
gchar *profile_id;
@@ -146,7 +147,7 @@ gs_plugin_packagekit_progress_cb (PkProgress *progress,
plugin_status = packagekit_status_enum_to_plugin_status (status);
if (plugin_status != GS_PLUGIN_STATUS_UNKNOWN)
- gs_plugin_status_update (plugin, NULL, plugin_status);
+ gs_plugin_status_update (plugin, data->app, plugin_status);
}
static void
@@ -284,6 +285,7 @@ gs_plugin_packagekit_resolve_packages (GsPlugin *plugin,
}
g_ptr_array_add (package_ids, NULL);
+ data.app = NULL;
data.plugin = plugin;
data.ptask = NULL;
data.profile_id = NULL;
@@ -311,7 +313,7 @@ gs_plugin_packagekit_resolve_packages (GsPlugin *plugin,
static gboolean
gs_plugin_packagekit_refine_from_desktop (GsPlugin *plugin,
- GsApp *app,
+ GsApp *app,
const gchar *filename,
GCancellable *cancellable,
GError **error)
@@ -321,6 +323,7 @@ gs_plugin_packagekit_refine_from_desktop (GsPlugin *plugin,
g_autoptr(PkResults) results = NULL;
g_autoptr(GPtrArray) packages = NULL;
+ data.app = app;
data.plugin = plugin;
data.ptask = NULL;
data.profile_id = g_path_get_basename (filename);
@@ -403,6 +406,7 @@ gs_plugin_packagekit_refine_updatedetails (GsPlugin *plugin,
package_ids[i++] = package_id;
}
+ data.app = NULL;
data.plugin = plugin;
data.ptask = NULL;
data.profile_id = NULL;
@@ -541,6 +545,7 @@ gs_plugin_packagekit_refine_details (GsPlugin *plugin,
}
g_ptr_array_add (package_ids, NULL);
+ data.app = NULL;
data.plugin = plugin;
data.ptask = NULL;
data.profile_id = g_strjoinv (",", (gchar **) package_ids->pdata);
@@ -580,6 +585,7 @@ gs_plugin_packagekit_refine_update_urgency (GsPlugin *plugin,
g_autoptr(PkPackageSack) sack = NULL;
g_autoptr(PkResults) results = NULL;
+ data.app = NULL;
data.plugin = plugin;
data.ptask = NULL;
data.profile_id = NULL;
@@ -774,6 +780,7 @@ gs_plugin_packagekit_refine_distro_upgrade (GsPlugin *plugin,
g_autoptr(PkResults) results = NULL;
g_autoptr(GsAppList) list = NULL;
+ data.app = app;
data.plugin = plugin;
data.ptask = NULL;
data.profile_id = NULL;
diff --git a/src/plugins/gs-plugin-packagekit.c b/src/plugins/gs-plugin-packagekit.c
index 189e1f1..8fd1a30 100644
--- a/src/plugins/gs-plugin-packagekit.c
+++ b/src/plugins/gs-plugin-packagekit.c
@@ -108,7 +108,7 @@ gs_plugin_packagekit_progress_cb (PkProgress *progress,
plugin_status = packagekit_status_enum_to_plugin_status (status);
if (plugin_status != GS_PLUGIN_STATUS_UNKNOWN)
- gs_plugin_status_update (plugin, NULL, plugin_status);
+ gs_plugin_status_update (plugin, data->app, plugin_status);
} else if (type == PK_PROGRESS_TYPE_PERCENTAGE) {
gint percentage;
@@ -292,12 +292,12 @@ gs_plugin_app_source_enable (GsPlugin *plugin,
ProgressData data;
g_autoptr(PkResults) results = NULL;
- data.app = NULL;
+ data.app = app;
data.plugin = plugin;
data.ptask = NULL;
/* do sync call */
- gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
+ gs_plugin_status_update (plugin, app, GS_PLUGIN_STATUS_WAITING);
results = pk_client_repo_enable (PK_CLIENT (plugin->priv->task),
gs_app_get_origin (app),
TRUE,
@@ -497,12 +497,12 @@ gs_plugin_app_source_disable (GsPlugin *plugin,
ProgressData data;
g_autoptr(PkResults) results = NULL;
- data.app = NULL;
+ data.app = app;
data.plugin = plugin;
data.ptask = NULL;
/* do sync call */
- gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
+ gs_plugin_status_update (plugin, app, GS_PLUGIN_STATUS_WAITING);
results = pk_client_repo_enable (PK_CLIENT (plugin->priv->task),
gs_app_get_id (app),
FALSE,
@@ -532,7 +532,7 @@ gs_plugin_app_source_remove (GsPlugin *plugin,
data.ptask = NULL;
/* do sync call */
- gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
+ gs_plugin_status_update (plugin, app, GS_PLUGIN_STATUS_WAITING);
results = pk_client_repo_remove (PK_CLIENT (plugin->priv->task),
pk_bitfield_from_enums (PK_TRANSACTION_FLAG_ENUM_NONE, -1),
gs_app_get_id (app),
@@ -567,7 +567,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
g_autoptr(PkResults) results = NULL;
g_auto(GStrv) package_ids = NULL;
- data.app = NULL;
+ data.app = app;
data.plugin = plugin;
data.ptask = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]