diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index b0b3da78..1a19a30a 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -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)) diff --git a/common/flatpak-dir.h b/common/flatpak-dir.h index ba8465bb..916d23ce 100644 --- a/common/flatpak-dir.h +++ b/common/flatpak-dir.h @@ -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, diff --git a/lib/flatpak-installation.c b/lib/flatpak-installation.c index 22b5e76f..f88118a5 100644 --- a/lib/flatpak-installation.c +++ b/lib/flatpak-installation.c @@ -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)