diff options
author | Alexander Larsson <alexl@redhat.com> | 2016-04-27 13:08:44 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2016-04-27 13:09:34 +0200 |
commit | b3b5da71c9235ec14cb7b71efd3bd99b79966aa6 (patch) | |
tree | 2e52a6fc07f6ef41ee652fe09ec9d3f9cc51c50e /lib | |
parent | 4b0621cfb0c714b3935068b25cf4b441bfe7165b (diff) | |
download | xdg-app-b3b5da71c9235ec14cb7b71efd3bd99b79966aa6.tar.gz |
lib: Use deploydata file directly
This means we seek a lot less. Also, we get the cached installed
size rather than recalculating it all the time.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/xdg-app-installation.c | 30 | ||||
-rw-r--r-- | lib/xdg-app-installed-ref-private.h | 2 | ||||
-rw-r--r-- | lib/xdg-app-installed-ref.c | 2 |
3 files changed, 14 insertions, 20 deletions
diff --git a/lib/xdg-app-installation.c b/lib/xdg-app-installation.c index 140be96..f6453ac 100644 --- a/lib/xdg-app-installation.c +++ b/lib/xdg-app-installation.c @@ -284,28 +284,28 @@ get_ref (XdgAppInstallation *self, { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); g_auto(GStrv) parts = NULL; - g_autofree char *origin = NULL; - g_autofree char *commit = NULL; + const char *origin = NULL; + const char *commit = NULL; g_autoptr(GFile) deploy_dir = NULL; g_autoptr(GFile) deploy_subdir = NULL; g_autofree char *deploy_path = NULL; g_autofree char *latest_commit = NULL; - g_auto(GStrv) subpaths = NULL; + g_autoptr(GVariant) deploy_data = NULL; + g_autofree const char **subpaths = NULL; gboolean is_current = FALSE; guint64 installed_size = 0; parts = g_strsplit (full_ref, "/", -1); - origin = xdg_app_dir_get_origin (priv->dir, full_ref, NULL, NULL); - commit = xdg_app_dir_read_active (priv->dir, full_ref, cancellable); - subpaths = xdg_app_dir_get_subpaths (priv->dir, full_ref, cancellable, NULL); + deploy_data = xdg_app_dir_get_deploy_data (priv->dir, full_ref, cancellable, NULL); + origin = xdg_app_deploy_data_get_origin (deploy_data); + commit = xdg_app_deploy_data_get_commit (deploy_data); + subpaths = xdg_app_deploy_data_get_subpaths (deploy_data); + installed_size = xdg_app_deploy_data_get_installed_size (deploy_data); - deploy_dir = xdg_app_dir_get_deploy_dir (priv->dir, full_ref); - if (deploy_dir && commit) - { - deploy_subdir = g_file_get_child (deploy_dir, commit); - deploy_path = g_file_get_path (deploy_subdir); - } + deploy_dir = xdg_app_dir_get_deploy_dir (priv->dir, full_ref); + deploy_subdir = g_file_get_child (deploy_dir, commit); + deploy_path = g_file_get_path (deploy_subdir); if (strcmp (parts[0], "app") == 0) { @@ -317,12 +317,6 @@ get_ref (XdgAppInstallation *self, latest_commit = xdg_app_dir_read_latest (priv->dir, origin, full_ref, NULL, NULL); - if (!xdg_app_dir_get_installed_size (priv->dir, - commit, &installed_size, - cancellable, - NULL)) - installed_size = 0; - return xdg_app_installed_ref_new (full_ref, commit, latest_commit, diff --git a/lib/xdg-app-installed-ref-private.h b/lib/xdg-app-installed-ref-private.h index 3b7bb59..fb07746 100644 --- a/lib/xdg-app-installed-ref-private.h +++ b/lib/xdg-app-installed-ref-private.h @@ -32,7 +32,7 @@ XdgAppInstalledRef *xdg_app_installed_ref_new (const char *full_ref, const char *commit, const char *latest_commit, const char *origin, - char **subpaths, + const char **subpaths, const char *deploy_dir, guint64 installed_size, gboolean current); diff --git a/lib/xdg-app-installed-ref.c b/lib/xdg-app-installed-ref.c index 853dc7b..d0b8793 100644 --- a/lib/xdg-app-installed-ref.c +++ b/lib/xdg-app-installed-ref.c @@ -338,7 +338,7 @@ xdg_app_installed_ref_new (const char *full_ref, const char *commit, const char *latest_commit, const char *origin, - char **subpaths, + const char**subpaths, const char *deploy_dir, guint64 installed_size, gboolean is_current) |