From 22b30f7074aa70040f55e35abd07470d945fea1a Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 15 Jan 2016 16:15:25 +0100 Subject: [PATCH] lib: Add xdg_app_installation_update_appdata_sync --- lib/xdg-app-installation.c | 43 ++++++++++++++++++++++++++++++++++++++ lib/xdg-app-installation.h | 6 ++++++ 2 files changed, 49 insertions(+) diff --git a/lib/xdg-app-installation.c b/lib/xdg-app-installation.c index 57379e3d..38b0c9c1 100644 --- a/lib/xdg-app-installation.c +++ b/lib/xdg-app-installation.c @@ -1117,6 +1117,49 @@ xdg_app_installation_fetch_remote_ref_sync (XdgAppInstallation *self, return NULL; } +static void +no_progress_cb (OstreeAsyncProgress *progress, gpointer user_data) +{ +} + +/** + * xdg_app_installation_update_appdata_sync: + * @self: a #XdgAppInstallation + * @remote_name: the name of the remote + * @arch: Architecture to update, or %NULL for the local machine arch + * @out_changed: (nullable): Set to %TRUE if the contents of the appdata changed, %FALSE if nothing changed + * @cancellable: (nullable): a #GCancellable + * @error: return location for a #GError + * + * Updates the local copy of appdata for @remote_name for the specified @arch. + * + * Returns: %TRUE on success, or %FALSE on error + */ +gboolean +xdg_app_installation_update_appdata_sync (XdgAppInstallation *self, + const char *remote_name, + const char *arch, + gboolean *out_changed, + GCancellable *cancellable, + GError **error) +{ + XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_autoptr(XdgAppDir) dir_clone = NULL; + g_autoptr(OstreeAsyncProgress) ostree_progress = NULL; + + /* Pull, prune, etc are not threadsafe, so we work on a copy */ + dir_clone = xdg_app_dir_clone (priv->dir); + + ostree_progress = ostree_async_progress_new_and_connect (no_progress_cb, NULL); + return xdg_app_dir_update_appdata (dir_clone, + remote_name, + arch, + out_changed, + ostree_progress, + cancellable, + error); +} + /** * xdg_app_installation_create_monitor: * @self: a #XdgAppInstallation diff --git a/lib/xdg-app-installation.h b/lib/xdg-app-installation.h index 10e7e02f..c6994fbc 100644 --- a/lib/xdg-app-installation.h +++ b/lib/xdg-app-installation.h @@ -163,5 +163,11 @@ XDG_APP_EXTERN XdgAppRemoteRef *xdg_app_installation_fetch_remote_ref_sync const char *branch, GCancellable *cancellable, GError **error); +XDG_APP_EXTERN gboolean xdg_app_installation_update_appdata_sync (XdgAppInstallation *self, + const char *remote_name, + const char *arch, + gboolean *out_changed, + GCancellable *cancellable, + GError **error); #endif /* __XDG_APP_INSTALLATION_H__ */