autoupdates: Updates not applied after fetching them for flatpak apps
I noticed two main problems which get in the way for flatpak autoupdates:
A brief of the code-path sequence that autoupdates are meant to work.
-
GS_PLUGIN_ACTION_DOWNLOAD
:gs-update-monitor
executes this action which makes all plugins download their respective updates in the background. For flatpak plugin, this executes a transaction withno-deploy=TRUE
which seems OK. -
GS_PLUGIN_ACTION_UPDATE
: Chained to the callback ofGS_PLUGIN_ACTION_DOWNLOAD
, this is supposed to actually update the apps. For flatpak plugin, this is a update transaction withno-pull=TRUE
(currentlyno-pull=TRUE
is not passed to the flatpak transaction though, Problem 1)
Based on my observation:
Between 1.
and 2.
the update monitor segregates the applist
between update_online
and update_offline
.
download_finished_cb (GObject *object, GAsyncResult *res, gpointer data) {
...
update_online = gs_app_list_new ();
update_offline = gs_app_list_new ();
for (guint i = 0; i < gs_app_list_length (list); i++) {
GsApp *app = gs_app_list_index (list, i);
if (_should_auto_update (app)) {
g_debug ("auto-updating %s", gs_app_get_unique_id (app));
gs_app_list_add (update_online, app);
} else {
gs_app_list_add (update_offline, app);
}
}
/* install any apps that can be installed LIVE */
if (gs_app_list_length (update_online) > 0) {
g_autoptr(GsPluginJob) plugin_job = NULL;
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_UPDATE,
"list", update_online,
NULL);
gs_plugin_loader_job_process_async (monitor->plugin_loader,
plugin_job,
monitor->cancellable,
update_finished_cb,
monitor);
}
...
}
The update_offline
list are the ones which probably needs a re-start and are updated using GS_PLUGIN_ACTION_GET_UPDATES_HISTORICAL
action(as per my understanding). Most of the flatpak apps are ending up in update_offline
list hence, they are not getting the actual deployment (because flatpak plugin have no implementation for GS_PLUGIN_ACTION_GET_UPDATES_HISTORICAL
).
I think the main culprit here is _should_auto_update
which is making flatpak apps go into the offline_updates
list (Problem 2) . It's querying each app's state so, a good place to check would be app's state while being updated.
Problem 1 is easily verifiable by running flatpak update --no-pull
after gnome-software has fetched all the updates in the background. All the apps were deployed after that command, in my testing.
Problem 2 needs more digging and making sure, apps do get listed in the online_updates
list, so that it gets correctly deployed via the flatpak plugin.