From 78601a42ce99d21cdeaaecb77e5f711da303e7d8 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 14 Jan 2016 16:44:00 +0100 Subject: [PATCH] lib: xdg_app_installation_fetch_remote_size_sync --- lib/test-lib.c | 19 +++++++++++++++++++ lib/xdg-app-installation.c | 20 ++++++++++++++++++++ lib/xdg-app-installation.h | 7 +++++++ 3 files changed, 46 insertions(+) diff --git a/lib/test-lib.c b/lib/test-lib.c index 83240034..5e55f51f 100644 --- a/lib/test-lib.c +++ b/lib/test-lib.c @@ -263,6 +263,25 @@ main (int argc, char *argv[]) xdg_app_ref_get_branch (XDG_APP_REF(ref)), xdg_app_ref_get_commit (XDG_APP_REF(ref)), xdg_app_remote_ref_get_remote_name (ref)); + + if (j == 0) + { + guint64 download_size; + guint64 installed_size; + if (!xdg_app_installation_fetch_remote_size_sync (installation, + xdg_app_remote_get_name (remote), + xdg_app_ref_get_commit (XDG_APP_REF(ref)), + &download_size, + &installed_size, + NULL, &error)) + { + g_print ("error fetching sizes: %s\n", error->message); + g_clear_error (&error); + } + else + g_print ("Download size: %"G_GUINT64_FORMAT" Installed size: %"G_GUINT64_FORMAT"\n", + download_size, installed_size); + } } } diff --git a/lib/xdg-app-installation.c b/lib/xdg-app-installation.c index a44e6ac2..95a26e48 100644 --- a/lib/xdg-app-installation.c +++ b/lib/xdg-app-installation.c @@ -974,6 +974,26 @@ xdg_app_installation_uninstall (XdgAppInstallation *self, } +gboolean +xdg_app_installation_fetch_remote_size_sync (XdgAppInstallation *self, + const char *remote_name, + const char *commit, + guint64 *download_size, + guint64 *installed_size, + GCancellable *cancellable, + GError **error) +{ + XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + + return xdg_app_dir_fetch_sizes (priv->dir, remote_name, commit, + download_size, + NULL, + NULL, + installed_size, + cancellable, + error); +} + GBytes * xdg_app_installation_fetch_remote_metadata_sync (XdgAppInstallation *self, const char *remote_name, diff --git a/lib/xdg-app-installation.h b/lib/xdg-app-installation.h index a86c06e9..10e7e02f 100644 --- a/lib/xdg-app-installation.h +++ b/lib/xdg-app-installation.h @@ -139,6 +139,13 @@ XDG_APP_EXTERN gboolean xdg_app_installation_uninstall GCancellable *cancellable, GError **error); +XDG_APP_EXTERN gboolean xdg_app_installation_fetch_remote_size_sync (XdgAppInstallation *self, + const char *remote_name, + const char *commit, + guint64 *download_size, + guint64 *installed_size, + GCancellable *cancellable, + GError **error); XDG_APP_EXTERN GBytes * xdg_app_installation_fetch_remote_metadata_sync (XdgAppInstallation *self, const char *remote_name, const char *commit,