Skip to content

Commit

Permalink
update: Update custom installations too
Browse files Browse the repository at this point in the history
Currently the update command only checks the default system and user
installations (unless overridden by a command line flag). This commit
makes it check custom installations as well, so they are not left out.

Care is taken so that an empty or broken installation doesn't cause the
whole update operation to fail.

Fixes flatpak#2006
  • Loading branch information
mwleeds committed Dec 6, 2018
1 parent 5be8493 commit 275f03f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions app/flatpak-builtins-update.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ flatpak_builtin_update (int argc,
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);

if (!flatpak_option_context_parse (context, options, &argc, &argv,
FLATPAK_BUILTIN_FLAG_STANDARD_DIRS,
FLATPAK_BUILTIN_FLAG_ALL_DIRS | FLATPAK_BUILTIN_FLAG_OPTIONAL_REPO,
&dirs, cancellable, error))
return FALSE;

Expand All @@ -108,9 +108,18 @@ flatpak_builtin_update (int argc,

transactions = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);

for (k = 0; k < dirs->len; k++)
/* Walk through the array backwards so we can safely remove */
for (k = dirs->len; k > 0; k--)
{
FlatpakTransaction *transaction = flatpak_cli_transaction_new (g_ptr_array_index (dirs, k), opt_yes, FALSE, error);
FlatpakDir *dir = g_ptr_array_index (dirs, k - 1);
OstreeRepo *repo = flatpak_dir_get_repo (dir);
if (repo == NULL)
{
g_ptr_array_remove_index (dirs, k - 1);
continue;
}

FlatpakTransaction *transaction = flatpak_cli_transaction_new (dir, opt_yes, FALSE, error);
if (transaction == NULL)
return FALSE;

Expand All @@ -120,7 +129,7 @@ flatpak_builtin_update (int argc,
flatpak_transaction_set_disable_dependencies (transaction, opt_no_deps);
flatpak_transaction_set_disable_related (transaction, opt_no_related);

g_ptr_array_add (transactions, transaction);
g_ptr_array_insert (transactions, 0, transaction);
}

kinds = flatpak_kinds_from_bools (opt_app, opt_runtime);
Expand Down

0 comments on commit 275f03f

Please sign in to comment.