diff --git a/lib/flatpak-error.h b/lib/flatpak-error.h index 58380e17..0499aa01 100644 --- a/lib/flatpak-error.h +++ b/lib/flatpak-error.h @@ -30,12 +30,15 @@ G_BEGIN_DECLS * FlatpakError: * @FLATPAK_ERROR_ALREADY_INSTALLED: App/runtime is already installed * @FLATPAK_ERROR_NOT_INSTALLED: App/runtime is not installed + * @FLATPAK_ERROR_ONLY_PULLED: App/runtime was only pulled into the local + * repository but not installed. * * Error codes for library functions. */ typedef enum { FLATPAK_ERROR_ALREADY_INSTALLED, FLATPAK_ERROR_NOT_INSTALLED, + FLATPAK_ERROR_ONLY_PULLED } FlatpakError; #define FLATPAK_ERROR flatpak_error_quark () diff --git a/lib/flatpak-installation.c b/lib/flatpak-installation.c index f88118a5..24c2d87c 100644 --- a/lib/flatpak-installation.c +++ b/lib/flatpak-installation.c @@ -1310,6 +1310,14 @@ flatpak_installation_install_ref_file (FlatpakInstallation *self, * * Install a new application or runtime. * + * Note that this function was originally written to always return a + * #FlatpakInstalledRef. Since 0.9.12.12, passing + * FLATPAK_INSTALL_FLAGS_NO_DEPLOY will only pull refs into the local flatpak + * repository without deploying them, however this function will + * be unable to provide information on the installed ref, so + * FLATPAK_ERROR_ONLY_PULLED will be set and the caller must respond + * accordingly. + * * Returns: (transfer full): The ref for the newly installed app or %NULL on failure */ FlatpakInstalledRef * @@ -1361,12 +1369,26 @@ flatpak_installation_install_full (FlatpakInstallation *self, else ostree_progress = ostree_async_progress_new_and_connect (no_progress_cb, NULL); - if (!flatpak_dir_install (dir_clone, FALSE, FALSE, + if (!flatpak_dir_install (dir_clone, + (flags & FLATPAK_INSTALL_FLAGS_NO_PULL) != 0, + (flags & FLATPAK_INSTALL_FLAGS_NO_DEPLOY) != 0, (flags & FLATPAK_INSTALL_FLAGS_NO_STATIC_DELTAS) != 0, ref, remote_name, (const char **)subpaths, ostree_progress, cancellable, error)) goto out; + /* Note that if the caller sets FLATPAK_INSTALL_FLAGS_NO_DEPLOY we must + * always return an error, as explained above. Otherwise get_ref will + * always return an error. */ + if ((flags & FLATPAK_INSTALL_FLAGS_NO_DEPLOY) != 0) + { + g_set_error (error, + FLATPAK_ERROR, FLATPAK_ERROR_ONLY_PULLED, + "As requested, %s was only pulled, but not installed", + name); + goto out; + } + result = get_ref (dir, ref, cancellable, error); if (result == NULL) goto out; @@ -1396,6 +1418,14 @@ out: * * Install a new application or runtime. * + * Note that this function was originally written to always return a + * #FlatpakInstalledRef. Since 0.9.12.12, passing + * FLATPAK_INSTALL_FLAGS_NO_DEPLOY will only pull refs into the local flatpak + * repository without deploying them, however this function will + * be unable to provide information on the installed ref, so + * FLATPAK_ERROR_ONLY_PULLED will be set and the caller must respond + * accordingly. + * * Returns: (transfer full): The ref for the newly installed app or %NULL on failure */ FlatpakInstalledRef * diff --git a/lib/flatpak-installation.h b/lib/flatpak-installation.h index 94be2ff1..1e0a8627 100644 --- a/lib/flatpak-installation.h +++ b/lib/flatpak-installation.h @@ -71,6 +71,8 @@ typedef enum { typedef enum { FLATPAK_INSTALL_FLAGS_NONE = 0, FLATPAK_INSTALL_FLAGS_NO_STATIC_DELTAS = (1 << 0), + FLATPAK_INSTALL_FLAGS_NO_DEPLOY = (1 << 2), + FLATPAK_INSTALL_FLAGS_NO_PULL = (1 << 3), } FlatpakInstallFlags; /**