Fix up subpath handling

Whenever we add a add a local dependency we add both the languages
based on the current locale, and (in case of an update) whatever was
installed before. We also properly merge this with any normally
specified (non-dependency) update (typically happens e.g. when just
doing a "flatpak update", which adds .Locale updates both as
dependencies and regular updates).

This means you can just configure a new language and then flatpak
update will pull everything with those languages.

Closes: #1098
Approved by: alexlarsson
This commit is contained in:
Alexander Larsson
2017-10-11 14:21:41 +02:00
committed by Atomic Bot
parent c763295944
commit 05e2afa8ce
2 changed files with 8 additions and 48 deletions

View File

@@ -40,6 +40,7 @@ typedef enum {
struct FlatpakTransactionOp {
char *remote;
char *ref;
/* NULL means unspecified (normally keep whatever was there before), [] means force everything */
char **subpaths;
char *commit;
GFile *bundle;
@@ -267,13 +268,8 @@ flatpak_transaction_add_op (FlatpakTransaction *self,
op = g_hash_table_lookup (self->refs, ref);
if (op != NULL)
{
/* Only override subpaths if already specified,
we always want the un-subpathed to win if specified. */
if (op->subpaths != NULL && op->subpaths[0] != NULL && subpaths != NULL)
{
g_strfreev (op->subpaths);
op->subpaths = g_strdupv ((char **)subpaths);
}
g_auto(GStrv) old_subpaths = op->subpaths;
op->subpaths = flatpak_subpaths_merge (old_subpaths, (char **)subpaths);
return op;
}
@@ -676,14 +672,6 @@ flatpak_transaction_run (FlatpakTransaction *self,
if (dir_ref_is_installed (self->dir, op->ref, NULL, &deploy_data))
{
g_autofree const char **current_subpaths = NULL;
/* When we update a dependency, we always inherit the subpaths
rather than use the default. */
g_strfreev (op->subpaths);
current_subpaths = flatpak_deploy_data_get_subpaths (deploy_data);
op->subpaths = g_strdupv ((char **)current_subpaths);
/* Don't use the remote from related ref on update, always use
the current remote. */
g_free (op->remote);

View File

@@ -9852,21 +9852,6 @@ flatpak_related_free (FlatpakRelated *self)
g_free (self);
}
static gboolean
string_in_array (GPtrArray *array,
const char *str)
{
int i;
for (i = 0; i < array->len; i++)
{
if (strcmp (g_ptr_array_index (array, i), str) == 0)
return TRUE;
}
return FALSE;
}
static void
add_related (FlatpakDir *self,
GPtrArray *related,
@@ -9881,8 +9866,8 @@ add_related (FlatpakDir *self,
{
g_autoptr(GVariant) deploy_data = NULL;
g_autofree const char **old_subpaths = NULL;
g_autoptr(GPtrArray) subpaths = g_ptr_array_new_with_free_func (g_free);
int i;
g_auto(GStrv) extra_subpaths = NULL;
g_auto(GStrv) subpaths = NULL;
FlatpakRelated *rel;
gboolean download;
gboolean delete = autodelete;
@@ -9926,34 +9911,21 @@ add_related (FlatpakDir *self,
if (g_str_has_suffix (extension, ".Locale"))
locale_subset = TRUE;
if (old_subpaths)
{
for (i = 0; old_subpaths[i] != NULL; i++)
g_ptr_array_add (subpaths, g_strdup (old_subpaths[i]));
}
if (locale_subset)
{
g_autofree char ** current_subpaths = flatpak_dir_get_locale_subpaths (self);
for (i = 0; current_subpaths[i] != NULL; i++)
{
g_autofree char *subpath = current_subpaths[i];
if (!string_in_array (subpaths, subpath))
g_ptr_array_add (subpaths, g_steal_pointer (&subpath));
}
extra_subpaths = flatpak_dir_get_locale_subpaths (self);
/* Always remove locale */
delete = TRUE;
}
g_ptr_array_add (subpaths, NULL);
subpaths = flatpak_subpaths_merge ((char **)old_subpaths, extra_subpaths);
rel = g_new0 (FlatpakRelated, 1);
rel->collection_id = g_strdup (extension_collection_id);
rel->ref = g_strdup (extension_ref);
rel->commit = g_strdup (checksum);
rel->subpaths = (char **)g_ptr_array_free (g_steal_pointer (&subpaths), FALSE);
rel->subpaths = g_steal_pointer (&subpaths);
rel->download = download;
rel->delete = delete;