Commit 05e9b3a2 authored by Philip Withnall's avatar Philip Withnall

flatpak: Ignore FLATPAK_ERROR_ALREADY_INSTALLED when installing apps

Somehow, sometimes, it might be possible for the state in gnome-software
to be out of date, and hence for g-s to start installing an app which is
actually already installed.

If that happens for an app, libflatpak will return
`FLATPAK_ERROR_ALREADY_INSTALLED` from
`flatpak_transaction_add_install()`. If it happens for a flatpakref or a
bundle, libflatpak will return the error from
`flatpak_transaction_run()` instead (since it needs to resolve the
flatpakrefs and bundles to refs before it can determine whether they’re
already installed).

Handle both of those cases in the flatpak plugin, marking the app as
installed if libflatpak returns that error code. The handling of it is
not especially pretty, since it needs to still fall through and refresh
the `GsApp` after marking it as installed.

Based on a downstream commit by Joaquim Rocha <jrocha@endlessm.com>.
Signed-off-by: Philip Withnall's avatarPhilip Withnall <withnall@endlessm.com>
parent d69f0c81
Pipeline #158377 passed with stage
in 3 minutes and 57 seconds