Skip to content

Commit

Permalink
install: Avoid a superfluous prompt to choose the only remote
Browse files Browse the repository at this point in the history
The install command can search available remotes for a specified flatpak
when a remote wasn't specified. In case only one remote is configured,
or in case only one of the configured remotes matches the ref specified,
we currently prompt the user to confirm use of the remote anyway (unless
-y/--assumeyes was used). Skip this prompt even when -y/--assumeyes was
not used, since the remote to use will still effectively be confirmed
when the list of refs to be installed is presented for confirmation.

Fixes #4364
  • Loading branch information
mwleeds committed Aug 23, 2021
1 parent ab86051 commit b34a39e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/flatpak-builtins-install.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro
if (remote_dir_pairs->len == 0)
return flatpak_fail (error, _("No remote refs found similar to ‘%s’"), argv[1]);

if (!flatpak_resolve_matching_remotes (opt_yes, remote_dir_pairs, argv[1], &chosen_pair, error))
if (!flatpak_resolve_matching_remotes (remote_dir_pairs, argv[1], &chosen_pair, error))
return FALSE;

remote = g_strdup (chosen_pair->remote_name);
Expand Down
9 changes: 6 additions & 3 deletions app/flatpak-builtins-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,7 @@ flatpak_resolve_matching_installed_refs (gboolean assume_yes,
}

gboolean
flatpak_resolve_matching_remotes (gboolean assume_yes,
GPtrArray *remote_dir_pairs,
flatpak_resolve_matching_remotes (GPtrArray *remote_dir_pairs,
const char *opt_search_ref,
RemoteDirPair **out_pair,
GError **error)
Expand All @@ -563,7 +562,11 @@ flatpak_resolve_matching_remotes (gboolean assume_yes,

g_assert (remote_dir_pairs->len > 0);

if (assume_yes && remote_dir_pairs->len == 1)
/* Here we use the only matching remote even if --assumeyes wasn't specified
* because the user will still be asked to confirm the operation in the next
* step after the dependencies are resolved.
*/
if (remote_dir_pairs->len == 1)
chosen = 1;

if (chosen == 0)
Expand Down
3 changes: 1 addition & 2 deletions app/flatpak-builtins-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ gboolean flatpak_resolve_matching_installed_refs (gboolean assume_yes,
GPtrArray *out_pairs,
GError **error);

gboolean flatpak_resolve_matching_remotes (gboolean assume_yes,
GPtrArray *remote_dir_pairs,
gboolean flatpak_resolve_matching_remotes (GPtrArray *remote_dir_pairs,
const char *opt_search_ref,
RemoteDirPair **out_pair,
GError **error);
Expand Down

0 comments on commit b34a39e

Please sign in to comment.