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.
tingping/wmclass
Alexander Larsson 2016-04-27 13:08:44 +02:00
parent 4b0621cfb0
commit b3b5da71c9
3 changed files with 14 additions and 20 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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)