flatpak_installed_ref_load_metadata: Find correct deploy directory

We're scoping the deploy directory by the subpaths these days, so
we need to take that into account when finding the metadata file.

Fixes https://github.com/flatpak/flatpak/issues/1014
This commit is contained in:
Alexander Larsson
2017-09-15 16:02:50 +02:00
parent 75c2db1a73
commit 2d0ceef446
3 changed files with 38 additions and 20 deletions

View File

@@ -1057,6 +1057,11 @@ flatpak_save_override_keyfile (GKeyFile *metakey,
return g_key_file_save_to_file (metakey, filename, error);
}
/* Note: passing a checksum only works here for non-sub-set deploys, not
e.g. a partial locale install, because it will not find the real
deploy directory. This is ok for now, because checksum is only
currently passed from flatpak_installation_launch() when launching
a particular version of an app, which is not used for locales. */
FlatpakDeploy *
flatpak_dir_load_deployed (FlatpakDir *self,
const char *ref,
@@ -1120,6 +1125,32 @@ flatpak_dir_get_deploy_dir (FlatpakDir *self,
return g_file_resolve_relative_path (self->basedir, ref);
}
char *
flatpak_dir_get_deploy_subdir (FlatpakDir *self,
const char *checksum,
const char * const * subpaths)
{
if (subpaths == NULL || *subpaths == NULL)
return g_strdup (checksum);
else
{
GString *str = g_string_new (checksum);
int i;
for (i = 0; subpaths[i] != NULL; i++)
{
const char *s = subpaths[i];
g_string_append_c (str, '-');
while (*s)
{
if (*s != '/')
g_string_append_c (str, *s);
s++;
}
}
return g_string_free (str, FALSE);
}
}
GFile *
flatpak_dir_get_unmaintained_extension_dir (FlatpakDir *self,
const char *name,
@@ -4950,25 +4981,7 @@ flatpak_dir_deploy (FlatpakDir *self,
commit_metadata = g_variant_get_child_value (commit_data, 0);
g_variant_lookup (commit_metadata, "xa.alt-id", "s", &alt_id);
if (subpaths == NULL || *subpaths == NULL)
checkout_basename = g_strdup (checksum);
else
{
GString *str = g_string_new (checksum);
int i;
for (i = 0; subpaths[i] != NULL; i++)
{
const char *s = subpaths[i];
g_string_append_c (str, '-');
while (*s)
{
if (*s != '/')
g_string_append_c (str, *s);
s++;
}
}
checkout_basename = g_string_free (str, FALSE);
}
checkout_basename = flatpak_dir_get_deploy_subdir (self, checksum, subpaths);
real_checkoutdir = g_file_get_child (deploy_base, checkout_basename);
if (g_file_query_exists (real_checkoutdir, cancellable))

View File

@@ -202,6 +202,9 @@ gint flatpak_dir_get_priority (FlatpakDir *self);
FlatpakDirStorageType flatpak_dir_get_storage_type (FlatpakDir *self);
GFile * flatpak_dir_get_deploy_dir (FlatpakDir *self,
const char *ref);
char * flatpak_dir_get_deploy_subdir (FlatpakDir *self,
const char *checksum,
const char * const * subpaths);
GFile * flatpak_dir_get_unmaintained_extension_dir (FlatpakDir *self,
const char *name,
const char *arch,

View File

@@ -569,6 +569,7 @@ get_ref (FlatpakDir *dir,
g_autoptr(GFile) deploy_subdir = NULL;
g_autofree char *deploy_path = NULL;
g_autofree char *latest_commit = NULL;
g_autofree char *deploy_subdirname = NULL;
g_autoptr(GVariant) deploy_data = NULL;
g_autofree const char **subpaths = NULL;
gboolean is_current = FALSE;
@@ -586,7 +587,8 @@ get_ref (FlatpakDir *dir,
installed_size = flatpak_deploy_data_get_installed_size (deploy_data);
deploy_dir = flatpak_dir_get_deploy_dir (dir, full_ref);
deploy_subdir = g_file_get_child (deploy_dir, commit);
deploy_subdirname = flatpak_dir_get_deploy_subdir (dir, commit, subpaths);
deploy_subdir = g_file_get_child (deploy_dir, deploy_subdirname);
deploy_path = g_file_get_path (deploy_subdir);
if (strcmp (parts[0], "app") == 0)