From 8decac7d7ff38196167cca507193b13e348b0787 Mon Sep 17 00:00:00 2001 From: Mario Sanchez Prada Date: Thu, 13 Oct 2016 18:12:36 +0100 Subject: [PATCH] Added new public API: flatpak_installation_update_remote_sync() Provides access to the functionality offered by the new internal API flatpak_dir_update_remote_configuration(), in a similar way to what can be done via the command 'flatpak remote-modify --update-metadata'. --- doc/reference/flatpak-sections.txt | 1 + lib/flatpak-installation.c | 39 ++++++++++++++++++++++++++++++ lib/flatpak-installation.h | 4 +++ 3 files changed, 44 insertions(+) diff --git a/doc/reference/flatpak-sections.txt b/doc/reference/flatpak-sections.txt index 0f117e35..7c32306e 100644 --- a/doc/reference/flatpak-sections.txt +++ b/doc/reference/flatpak-sections.txt @@ -29,6 +29,7 @@ flatpak_installation_install_bundle flatpak_installation_drop_caches flatpak_installation_modify_remote flatpak_installation_remove_remote +flatpak_installation_update_remote_sync flatpak_get_default_arch FlatpakProgressCallback FlatpakUpdateFlags diff --git a/lib/flatpak-installation.c b/lib/flatpak-installation.c index 4ab6e6b5..0e473ced 100644 --- a/lib/flatpak-installation.c +++ b/lib/flatpak-installation.c @@ -798,6 +798,45 @@ flatpak_installation_remove_remote (FlatpakInstallation *self, return TRUE; } +/** + * flatpak_installation_update_remote_sync: + * @self: a #FlatpakInstallation + * @name: the name of the remote to update + * @cancellable: (nullable): a #GCancellable + * @error: return location for a #GError + * + * Updates the local configuration of a remote repository by fetching + * the related information from the summary file in the remote OSTree + * repository and committing the changes to the local installation. + * + * Returns: %TRUE if the remote has been updated successfully + * + * Since: 0.6.13 + */ +gboolean +flatpak_installation_update_remote_sync (FlatpakInstallation *self, + const char *name, + GCancellable *cancellable, + GError **error) +{ + g_autoptr(FlatpakDir) dir = flatpak_installation_get_dir (self); + g_autoptr(FlatpakDir) dir_clone = NULL; + + /* We clone the dir here to make sure we re-read the latest ostree repo config, in case + it has local changes */ + dir_clone = flatpak_dir_clone (dir); + if (!flatpak_dir_ensure_repo (dir_clone, cancellable, error)) + return FALSE; + + if (!flatpak_dir_update_remote_configuration (dir, name, cancellable, error)) + return FALSE; + + /* Make sure we pick up the new config */ + flatpak_installation_drop_caches (self, NULL, NULL); + + return TRUE; +} + /** * flatpak_installation_get_remote_by_name: * @self: a #FlatpakInstallation diff --git a/lib/flatpak-installation.h b/lib/flatpak-installation.h index bdaeb52d..1b059e41 100644 --- a/lib/flatpak-installation.h +++ b/lib/flatpak-installation.h @@ -158,6 +158,10 @@ FLATPAK_EXTERN gboolean flatpak_installation_remove_remote (Flatpak const char *name, GCancellable *cancellable, GError **error); +FLATPAK_EXTERN gboolean flatpak_installation_update_remote_sync (FlatpakInstallation *self, + const char *name, + GCancellable *cancellable, + GError **error); FLATPAK_EXTERN char * flatpak_installation_load_app_overrides (FlatpakInstallation *self, const char *app_id, GCancellable *cancellable,