summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUmang Jain <umang@endlessm.com>2018-09-11 21:25:49 +0530
committerAtomic Bot <atomic-devel@projectatomic.io>2018-11-07 12:02:14 +0000
commit94969d5057a232b0036854463f32562ab368f56e (patch)
tree005d3fd4efe9a27de5f6574bc5f377ad0bbcea26
parentadd199a1f95a2bfa2f5b223e1470729f35f64620 (diff)
downloadflatpak-94969d5057a232b0036854463f32562ab368f56e.tar.gz
Installation: Add flatpak_installation_get_min_free_space_bytes
A convenience wrapper around ostree_repo_get_min_free_space_bytes(). Clients programs like gnome-software can get the value of minimum free space as defined in the OSTree repo. This can be useful in various disk-space checks these client program can implement. At Endless, we have downstream heuristics in gnome-software which determine the success/failure likelihood of an install/update operation to some extend. Depending upon the likelihood of the success/failure we dispatch install/update/auto-update operations. With client programs gaining features such as auto-updates, it makes sense to have a min-free-space API so that these programs can check free-space availablity vs minimum free space defined by user inside OSTree's repo before auto-updating. Although, OSTree will certainly fail operations over-stepping min-free-space's value; It's just a matter of convenience to provide a way to query the value to client programs as well. Closes: #2274 Approved by: matthiasclasen
-rw-r--r--common/flatpak-installation.c36
-rw-r--r--common/flatpak-installation.h3
-rw-r--r--configure.ac2
-rw-r--r--doc/reference/flatpak-sections.txt1
4 files changed, 41 insertions, 1 deletions
diff --git a/common/flatpak-installation.c b/common/flatpak-installation.c
index a3650d66..68397bae 100644
--- a/common/flatpak-installation.c
+++ b/common/flatpak-installation.c
@@ -1520,6 +1520,42 @@ flatpak_installation_get_config (FlatpakInstallation *self,
}
/**
+ * flatpak_installation_get_min_free_space_bytes:
+ * @self: a #FlatpakInstallation
+ * @out_bytes: (out): Location to store the result
+ * @error: Return location for a #GError
+ *
+ * Returns the min-free-space config value from the OSTree repository of this installation.
+ *
+ * Applications can use this value, together with information about the available
+ * disk space and the size of pending updates or installs, to estimate whether a
+ * pull operation will fail due to running out of disk space.
+ *
+ * Returns: %TRUE on success, or %FALSE on error.
+ * Since: 1.1
+ */
+gboolean
+flatpak_installation_get_min_free_space_bytes (FlatpakInstallation *self,
+ guint64 *out_bytes,
+ GError **error)
+{
+ g_autoptr(FlatpakDir) dir = NULL;
+ g_autoptr(FlatpakDir) dir_clone = NULL;
+
+ dir = flatpak_installation_get_dir (self, NULL);
+ if (dir == NULL)
+ return FALSE;
+
+ /* We clone the dir here to make sure we re-read the latest ostree repo config, in case
+ it has local changes */
+ dir_clone = flatpak_dir_clone (dir);
+ if (!flatpak_dir_ensure_repo (dir_clone, NULL, error))
+ return FALSE;
+
+ return ostree_repo_get_min_free_space_bytes (flatpak_dir_get_repo (dir_clone), out_bytes, error);
+}
+
+/**
* flatpak_installation_update_remote_sync:
* @self: a #FlatpakInstallation
* @name: the name of the remote to update
diff --git a/common/flatpak-installation.h b/common/flatpak-installation.h
index 1950e71f..6720794b 100644
--- a/common/flatpak-installation.h
+++ b/common/flatpak-installation.h
@@ -261,6 +261,9 @@ FLATPAK_EXTERN gboolean flatpak_installation_set_config_sync (Flatp
const char *value,
GCancellable *cancellable,
GError **error);
+FLATPAK_EXTERN gboolean flatpak_installation_get_min_free_space_bytes (FlatpakInstallation *self,
+ guint64 *out_bytes,
+ GError **error);
FLATPAK_EXTERN char * flatpak_installation_get_config (FlatpakInstallation *self,
const char *key,
GCancellable *cancellable,
diff --git a/configure.ac b/configure.ac
index 78c98edc..042c8b1c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,7 @@ AC_INIT([Flatpak],
GLIB_REQS=2.44
SYSTEM_BWRAP_REQS=0.2.1
SYSTEM_DBUS_PROXY_REQS=0.1.0
-OSTREE_REQS=2018.7
+OSTREE_REQS=2018.9
AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE
diff --git a/doc/reference/flatpak-sections.txt b/doc/reference/flatpak-sections.txt
index 062766e2..db9c9912 100644
--- a/doc/reference/flatpak-sections.txt
+++ b/doc/reference/flatpak-sections.txt
@@ -21,6 +21,7 @@ flatpak_installation_get_current_installed_app
flatpak_installation_get_display_name
flatpak_installation_get_id
flatpak_installation_get_installed_ref
+flatpak_installation_get_min_free_space_bytes
flatpak_installation_get_priority
flatpak_installation_get_storage_type
flatpak_installation_list_installed_refs