forked from Mirrors/flatpak-builder
Remove all appstream checkouts and mirrored refs when deleting remote
parent
3d18255ba3
commit
abdbb17a72
|
@ -47,6 +47,14 @@ xdg_app_builtin_delete_remote (int argc, char **argv, GCancellable *cancellable,
|
|||
|
||||
remote_name = argv[1];
|
||||
|
||||
if (!xdg_app_dir_remove_all_refs (dir, remote_name,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!xdg_app_dir_remove_appstream (dir, remote_name,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!ostree_repo_remote_change (xdg_app_dir_get_repo (dir), NULL,
|
||||
OSTREE_REPO_REMOTE_CHANGE_DELETE,
|
||||
remote_name, NULL,
|
||||
|
|
|
@ -593,6 +593,67 @@ xdg_app_dir_mark_changed (XdgAppDir *self,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_dir_remove_appstream (XdgAppDir *self,
|
||||
const char *remote,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GFile) appstream_dir = NULL;
|
||||
g_autoptr(GFile) remote_dir = NULL;
|
||||
g_autofree char *prefix = NULL;
|
||||
g_autoptr(GHashTable) refs = NULL;
|
||||
|
||||
if (!xdg_app_dir_ensure_repo (self, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
appstream_dir = g_file_get_child (xdg_app_dir_get_path (self), "appstream");
|
||||
remote_dir = g_file_get_child (appstream_dir, remote);
|
||||
|
||||
if (g_file_query_exists (remote_dir, cancellable) &&
|
||||
!gs_shutil_rm_rf (remote_dir, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_dir_remove_all_refs (XdgAppDir *self,
|
||||
const char *remote,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GFile) appstream_dir = NULL;
|
||||
g_autoptr(GFile) remote_dir = NULL;
|
||||
g_autofree char *prefix = NULL;
|
||||
g_autoptr(GHashTable) refs = NULL;
|
||||
GHashTableIter hash_iter;
|
||||
gpointer key;
|
||||
|
||||
if (!xdg_app_dir_ensure_repo (self, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
prefix = g_strdup_printf ("%s:", remote);
|
||||
|
||||
if (!ostree_repo_list_refs (self->repo,
|
||||
NULL,
|
||||
&refs,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
g_hash_table_iter_init (&hash_iter, refs);
|
||||
while (g_hash_table_iter_next (&hash_iter, &key, NULL))
|
||||
{
|
||||
const char *refspec = key;
|
||||
|
||||
if (g_str_has_prefix (refspec, prefix) &&
|
||||
!xdg_app_dir_remove_ref (self, remote, refspec + strlen (prefix), cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_dir_update_appstream (XdgAppDir *self,
|
||||
const char *remote,
|
||||
|
|
|
@ -130,6 +130,10 @@ gboolean xdg_app_dir_ensure_repo (XdgAppDir *self,
|
|||
GError **error);
|
||||
gboolean xdg_app_dir_mark_changed (XdgAppDir *self,
|
||||
GError **error);
|
||||
gboolean xdg_app_dir_remove_appstream(XdgAppDir *self,
|
||||
const char *remote,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean xdg_app_dir_update_appstream(XdgAppDir *self,
|
||||
const char *remote,
|
||||
const char *arch,
|
||||
|
@ -210,6 +214,10 @@ gboolean xdg_app_dir_undeploy_all (XdgAppDir *self,
|
|||
gboolean *was_deployed_out,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean xdg_app_dir_remove_all_refs (XdgAppDir *self,
|
||||
const char *remote,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean xdg_app_dir_remove_ref (XdgAppDir *self,
|
||||
const char *remote_name,
|
||||
const char *ref,
|
||||
|
|
Loading…
Reference in New Issue