mirror of
https://github.com/flatpak/flatpak.git
synced 2026-05-18 21:55:22 -04:00
lib: Add methods to clean up refs in the local repository
In some cases, a user might pull a ref into the local repository and not deploy it by using FLATPAK_INSTALL_FLAGS_NO_DEPLOY. Later on, that user might decide that they don't want to deploy the ref after all, but there was no way to remove that ref from the local repository in the public API, so it takes up disk space. Add flatpak_installation_remove_local_ref_sync to remove a given ref from the local repository if the ref is known and flatpak_installation_cleanup_local_refs_sync to remove all undeployed refs. Fixes #1031 Closes: #1034 Approved by: alexlarsson
This commit is contained in:
committed by
Atomic Bot
parent
cdbfb001df
commit
6236a60a1b
@@ -2041,3 +2041,59 @@ flatpak_installation_list_installed_related_refs_sync (FlatpakInstallation *self
|
||||
|
||||
return g_steal_pointer (&refs);
|
||||
}
|
||||
|
||||
/**
|
||||
* flatpak_installation_remove_local_ref_sync
|
||||
* @self: a #FlatpakInstallation
|
||||
* @remote_name: the name of the remote
|
||||
* @ref: the ref
|
||||
* @cancellable: (nullable): a #GCancellable
|
||||
* @error: return location for a #GError
|
||||
*
|
||||
* Remove the OSTree ref given by @remote_name:@ref from the local flatpak
|
||||
* repository. The next time the underlying OSTree repo is pruned, objects
|
||||
* which were attached to that ref will be removed. This is useful if you
|
||||
* pulled a flatpak ref using flatpak_installation_install_full() and
|
||||
* specified %FLATPAK_INSTALL_FLAGS_NO_DEPLOY but then decided not to
|
||||
* deploy the ref later on and want to remove the local ref to prevent it
|
||||
* from taking up disk space.
|
||||
*
|
||||
* Returns: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
flatpak_installation_remove_local_ref_sync (FlatpakInstallation *self,
|
||||
const char *remote_name,
|
||||
const char *ref,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(FlatpakDir) dir = flatpak_installation_get_dir (self);
|
||||
|
||||
return flatpak_dir_remove_ref (dir, remote_name, ref, cancellable, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* flatpak_installation_cleanup_local_refs_sync
|
||||
* @self: a #FlatpakInstallation
|
||||
* @cancellable: (nullable): a #GCancellable
|
||||
* @error: return location for a #GError
|
||||
*
|
||||
* Remove all OSTree refs from the local flatpak repository which are not
|
||||
* in a deployed state. The next time the underlying OSTree repo is pruned,
|
||||
* objects which were attached to that ref will be removed. This is useful if
|
||||
* you pulled a flatpak refs using flatpak_installation_install_full() and
|
||||
* specified %FLATPAK_INSTALL_FLAGS_NO_DEPLOY but then decided not to
|
||||
* deploy the refs later on and want to remove the local refs to prevent them
|
||||
* from taking up disk space.
|
||||
*
|
||||
* Returns: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
flatpak_installation_cleanup_local_refs_sync (FlatpakInstallation *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(FlatpakDir) dir = flatpak_installation_get_dir (self);
|
||||
|
||||
return flatpak_dir_cleanup_undeployed_refs (dir, cancellable, error);
|
||||
}
|
||||
|
||||
@@ -309,4 +309,13 @@ FLATPAK_EXTERN GPtrArray * flatpak_installation_list_installed_related_ref
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
FLATPAK_EXTERN gboolean flatpak_installation_remove_local_ref_sync (FlatpakInstallation *self,
|
||||
const char *remote_name,
|
||||
const char *ref,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
FLATPAK_EXTERN gboolean flatpak_installation_cleanup_local_refs_sync (FlatpakInstallation *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
#endif /* __FLATPAK_INSTALLATION_H__ */
|
||||
|
||||
Reference in New Issue
Block a user