lib: Add support for FLATPAK_INSTALL_FLAGS_NO_DEPLOY / NO_PULL

We have the same flags for flatpak_installation_update and we use
flatpak_dir_install from within FlatpakInstallation but always set
the no_pull/no_deploy flags to FALSE. Previously, passing
FLATPAK_INSTALL_FLAGS_NO_PULL and FLATPAK_INSTALL_FLAGS_NO_DEPLOY
wouldn't do anything because of that.

This has the unfortunate side effect of always returning an error
when FLATPAK_INSTALL_FLAGS_NO_DEPLOY is passed, because
flatpak_installation_install_full tries to get a FlatpakInstalledRef
for the flatpak when it is installed, but obviously it can't do that
since installing an app in an undeployed state doesn't "install" it
so much as just cloning it to the local repository.

As a result, when FLATPAK_INSTALL_FLAGS_NO_PULL is passed, the
FLATPAK_ERROR_ONLY_PULLED Will be set and the caller must respond
accordingly.
This commit is contained in:
Sam Spilsbury
2017-09-14 11:51:34 +08:00
committed by Alexander Larsson
parent 7be94770e3
commit 5ecfd0ca66
3 changed files with 36 additions and 1 deletions

View File

@@ -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 ()

View File

@@ -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 *

View File

@@ -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;
/**