summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2016-04-14 19:29:40 +0200
committerAlexander Larsson <alexl@redhat.com>2016-04-14 19:29:40 +0200
commit1dd993cad6260aa181e767b5370e27f72ffd6217 (patch)
tree01f76c7d75c089baaeb1ac083a69709500be8aa1 /lib
parent664fb128e755a3edb37a9fd8f63db404970b1ff4 (diff)
downloadxdg-app-1dd993cad6260aa181e767b5370e27f72ffd6217.tar.gz
lib: Add new cache based getters for metadata and size
Diffstat (limited to 'lib')
-rw-r--r--lib/test-lib.c35
-rw-r--r--lib/xdg-app-installation.c75
-rw-r--r--lib/xdg-app-installation.h12
3 files changed, 119 insertions, 3 deletions
diff --git a/lib/test-lib.c b/lib/test-lib.c
index 6032ee9..df641df 100644
--- a/lib/test-lib.c
+++ b/lib/test-lib.c
@@ -332,19 +332,35 @@ main (int argc, char *argv[])
else
g_print ("Download size: %"G_GUINT64_FORMAT" Installed size: %"G_GUINT64_FORMAT"\n",
download_size, installed_size);
+
+ if (!xdg_app_installation_fetch_remote_size_sync2 (installation,
+ xdg_app_remote_get_name (remote),
+ XDG_APP_REF(ref),
+ &download_size,
+ &installed_size,
+ NULL, &error))
+ {
+ g_print ("error fetching sizes2: %s\n", error->message);
+ g_clear_error (&error);
+ }
+ else
+ g_print ("Download size2: %"G_GUINT64_FORMAT" Installed size2: %"G_GUINT64_FORMAT"\n",
+ download_size, installed_size);
+
}
}
}
- g_print ("\n**** Getting remote gedit master on %s\n", xdg_app_remote_get_name (remote));
+ g_print ("\n**** Getting remote platform 3.20 on %s\n", xdg_app_remote_get_name (remote));
error = NULL;
remote_ref = xdg_app_installation_fetch_remote_ref_sync (installation, xdg_app_remote_get_name (remote),
- XDG_APP_REF_KIND_APP,
- "org.gnome.gedit", NULL, "master",
+ XDG_APP_REF_KIND_RUNTIME,
+ "org.gnome.Platform", NULL, "3.20",
NULL, &error);
if (remote_ref)
{
GBytes *metadata;
+ GBytes *metadata2;
g_print ("%d %s %s %s %s %s\n",
xdg_app_ref_get_kind (XDG_APP_REF(remote_ref)),
@@ -366,6 +382,19 @@ main (int argc, char *argv[])
g_print ("error: %s\n", error->message);
g_clear_error (&error);
}
+
+ metadata2 = xdg_app_installation_fetch_remote_metadata_sync2 (installation, xdg_app_remote_get_name (remote),
+ XDG_APP_REF(remote_ref), NULL, &error);
+ if (metadata2)
+ {
+ g_print ("metadata2: %s\n", (char *)g_bytes_get_data (metadata2, NULL));
+ }
+ else
+ {
+ g_print ("fetch error\n");
+ g_print ("error: %s\n", error->message);
+ g_clear_error (&error);
+ }
}
else
{
diff --git a/lib/xdg-app-installation.c b/lib/xdg-app-installation.c
index 0219be4..92e347b 100644
--- a/lib/xdg-app-installation.c
+++ b/lib/xdg-app-installation.c
@@ -1298,6 +1298,8 @@ xdg_app_installation_uninstall (XdgAppInstallation *self,
* to pull a commit from a remote repository, and about the amount of
* local disk space that is required to check out this commit.
*
+ * This is deprectated, use xdg_app_installation_fetch_remote_size_sync2 instead.
+ *
* Returns: %TRUE, unless an error occurred
*/
gboolean
@@ -1321,6 +1323,45 @@ xdg_app_installation_fetch_remote_size_sync (XdgAppInstallation *self,
}
/**
+ * xdg_app_installation_fetch_remote_size_sync2:
+ * @self: a #XdgAppInstallation
+ * @remote_name: the name of the remote
+ * @ref: the ref
+ * @download_size: (out): return location for the (maximum) download size
+ * @installed_size: (out): return location for the installed size
+ * @cancellable: (nullable): a #GCancellable
+ * @error: return location for a #GError
+ *
+ * Gets information about the maximum amount of data that needs to be transferred
+ * to pull the ref from a remote repository, and about the amount of
+ * local disk space that is required to check out this commit.
+ *
+ * Note that if there are locally available data that are in the ref, which is commong
+ * for instance if you're doing an update then the real download size may be smaller
+ * than what is returned here.
+ *
+ * Returns: %TRUE, unless an error occurred
+ */
+gboolean
+xdg_app_installation_fetch_remote_size_sync2 (XdgAppInstallation *self,
+ const char *remote_name,
+ XdgAppRef *ref,
+ guint64 *download_size,
+ guint64 *installed_size,
+ GCancellable *cancellable,
+ GError **error)
+{
+ XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self);
+ g_autofree char *full_ref = xdg_app_ref_format_ref (ref);
+
+ return xdg_app_dir_fetch_ref_cache (priv->dir, remote_name, full_ref,
+ download_size, installed_size,
+ NULL,
+ cancellable,
+ error);
+}
+
+/**
* xdg_app_installation_fetch_remote_metadata_sync:
* @self: a #XdgAppInstallation
* @remote_name: the name of the remote
@@ -1330,6 +1371,8 @@ xdg_app_installation_fetch_remote_size_sync (XdgAppInstallation *self,
*
* Obtains the metadata file from a commit.
*
+ * This is deprecated, use xdg_app_installation_fetch_remote_metadata_sync2
+ *
* Returns: (transfer full): a #GBytes containing the xdg-app metadata file,
* or %NULL if an error occurred
*/
@@ -1354,6 +1397,38 @@ xdg_app_installation_fetch_remote_metadata_sync (XdgAppInstallation *self,
return g_steal_pointer (&bytes);
}
+/**
+ * xdg_app_installation_fetch_remote_metadata_sync2:
+ * @self: a #XdgAppInstallation
+ * @remote_name: the name of the remote
+ * @commit: the commit
+ * @cancellable: (nullable): a #GCancellable
+ * @error: return location for a #GError
+ *
+ * Obtains the metadata file from a commit.
+ *
+ * Returns: (transfer full): a #GBytes containing the xdg-app metadata file,
+ * or %NULL if an error occurred
+ */
+GBytes *
+xdg_app_installation_fetch_remote_metadata_sync2 (XdgAppInstallation *self,
+ const char *remote_name,
+ XdgAppRef *ref,
+ GCancellable *cancellable,
+ GError **error)
+{
+ XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self);
+ g_autofree char *full_ref = xdg_app_ref_format_ref (ref);
+ char *res = NULL;
+
+ if (!xdg_app_dir_fetch_ref_cache (priv->dir, remote_name, full_ref,
+ NULL, NULL,
+ &res,
+ cancellable, error))
+ return NULL;
+
+ return g_bytes_new_take (res, strlen (res));
+}
/**
* xdg_app_installation_list_remote_refs_sync:
diff --git a/lib/xdg-app-installation.h b/lib/xdg-app-installation.h
index 11bb4f4..025e018 100644
--- a/lib/xdg-app-installation.h
+++ b/lib/xdg-app-installation.h
@@ -178,11 +178,23 @@ XDG_APP_EXTERN gboolean xdg_app_installation_fetch_remote_size_sync
guint64 *installed_size,
GCancellable *cancellable,
GError **error);
+XDG_APP_EXTERN gboolean xdg_app_installation_fetch_remote_size_sync2 (XdgAppInstallation *self,
+ const char *remote_name,
+ XdgAppRef *ref,
+ 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,
GCancellable *cancellable,
GError **error);
+XDG_APP_EXTERN GBytes * xdg_app_installation_fetch_remote_metadata_sync2 (XdgAppInstallation *self,
+ const char *remote_name,
+ XdgAppRef *ref,
+ GCancellable *cancellable,
+ GError **error);
XDG_APP_EXTERN GPtrArray * xdg_app_installation_list_remote_refs_sync (XdgAppInstallation *self,
const char *remote_name,
GCancellable *cancellable,