libostree: Move prune into OstreeRepo namespace

More library work.
This commit is contained in:
Colin Walters 2013-07-09 20:05:31 -04:00
parent 2aa0251b1b
commit 5dd0d5da40
8 changed files with 41 additions and 73 deletions

View File

@ -33,6 +33,7 @@ libostree_la_SOURCES = src/libostree/ostree.h \
src/libostree/ostree-repo.c \
src/libostree/ostree-repo-checkout.c \
src/libostree/ostree-repo-libarchive.c \
src/libostree/ostree-repo-prune.c \
src/libostree/ostree-repo-refs.c \
src/libostree/ostree-repo-traverse.c \
src/libostree/ostree-repo.h \

View File

@ -22,8 +22,6 @@ bin_PROGRAMS += ostree
ostree_SOURCES = src/ostree/main.c \
src/ostree/ostree-curl-fetcher.h \
src/ostree/ostree-curl-fetcher.c \
src/ostree/ostree-prune.h \
src/ostree/ostree-prune.c \
src/ostree/ot-builtin-admin.c \
src/ostree/ot-builtins.h \
src/ostree/ot-builtin-cat.c \

View File

@ -1,6 +1,6 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
* Copyright (C) 2011,2013 Colin Walters <walters@verbum.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -22,7 +22,7 @@
#include "config.h"
#include "ostree-prune.h"
#include "ostree-repo.h"
typedef struct {
OstreeRepo *repo;
@ -36,7 +36,7 @@ typedef struct {
static gboolean
maybe_prune_loose_object (OtPruneData *data,
OstreePruneFlags flags,
OstreeRepoPruneFlags flags,
const char *checksum,
OstreeObjectType objtype,
GCancellable *cancellable,
@ -52,7 +52,7 @@ maybe_prune_loose_object (OtPruneData *data,
if (!g_hash_table_lookup_extended (data->reachable, key, NULL, NULL))
{
if (!(flags & OSTREE_PRUNE_FLAGS_NO_PRUNE))
if (!(flags & OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE))
{
gs_unref_object GFileInfo *info = NULL;
@ -85,14 +85,14 @@ maybe_prune_loose_object (OtPruneData *data,
}
gboolean
ostree_prune (OstreeRepo *repo,
OstreePruneFlags flags,
gint depth,
gint *out_objects_total,
gint *out_objects_pruned,
guint64 *out_pruned_object_size_total,
GCancellable *cancellable,
GError **error)
ostree_repo_prune (OstreeRepo *repo,
OstreeRepoPruneFlags flags,
gint depth,
gint *out_objects_total,
gint *out_objects_pruned,
guint64 *out_pruned_object_size_total,
GCancellable *cancellable,
GError **error)
{
gboolean ret = FALSE;
GHashTableIter hash_iter;
@ -101,7 +101,7 @@ ostree_prune (OstreeRepo *repo,
gs_unref_hashtable GHashTable *all_refs = NULL;
gs_free char *formatted_freed_size = NULL;
OtPruneData data;
gboolean refs_only = flags & OSTREE_PRUNE_FLAGS_REFS_ONLY;
gboolean refs_only = flags & OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY;
memset (&data, 0, sizeof (data));

View File

@ -332,6 +332,20 @@ gboolean ostree_repo_traverse_commit (OstreeRepo *repo,
GCancellable *cancellable,
GError **error);
typedef enum {
OSTREE_REPO_PRUNE_FLAGS_NONE,
OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE,
OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY
} OstreeRepoPruneFlags;
gboolean ostree_repo_prune (OstreeRepo *repo,
OstreeRepoPruneFlags flags,
gint depth,
gint *out_objects_total,
gint *out_objects_pruned,
guint64 *out_pruned_object_size_total,
GCancellable *cancellable,
GError **error);
G_END_DECLS

View File

@ -1,43 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2013 Colin Walters <walters@verbum.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the licence or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#pragma once
#include "ostree.h"
G_BEGIN_DECLS
typedef enum {
OSTREE_PRUNE_FLAGS_NONE,
OSTREE_PRUNE_FLAGS_NO_PRUNE,
OSTREE_PRUNE_FLAGS_REFS_ONLY
} OstreePruneFlags;
gboolean ostree_prune (OstreeRepo *repo,
OstreePruneFlags flags,
gint depth,
gint *out_objects_total,
gint *out_objects_pruned,
guint64 *out_pruned_object_size_total,
GCancellable *cancellable,
GError **error);
G_END_DECLS

View File

@ -27,8 +27,7 @@
#include "ot-deployment.h"
#include "ot-config-parser.h"
#include "otutil.h"
#include "ostree-core.h"
#include "ostree-prune.h"
#include "ostree.h"
#include "libgsystem.h"
static gboolean
@ -463,9 +462,9 @@ generate_deployment_refs_and_prune (GFile *sysroot,
goto out;
}
if (!ostree_prune (repo, OSTREE_PRUNE_FLAGS_REFS_ONLY, 0,
&n_objects_total, &n_objects_pruned, &freed_space,
cancellable, error))
if (!ostree_repo_prune (repo, OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY, 0,
&n_objects_total, &n_objects_pruned, &freed_space,
cancellable, error))
goto out;
if (freed_space > 0)
{

View File

@ -28,8 +28,7 @@
#include "ot-config-parser.h"
#include "ot-bootloader-syslinux.h"
#include "otutil.h"
#include "ostree-core.h"
#include "ostree-prune.h"
#include "ostree.h"
#include "libgsystem.h"
OtOrderedHash *

View File

@ -23,7 +23,7 @@
#include "config.h"
#include "ot-builtins.h"
#include "ostree-prune.h"
#include "ostree.h"
#include <glib/gi18n.h>
#include <glib/gprintf.h>
@ -47,7 +47,7 @@ ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GError **error)
GCancellable *cancellable = NULL;
gs_unref_object OstreeRepo *repo = NULL;
gs_free char *formatted_freed_size = NULL;
OstreePruneFlags pruneflags = 0;
OstreeRepoPruneFlags pruneflags = 0;
gint n_objects_total;
gint n_objects_pruned;
guint64 objsize_total;
@ -63,13 +63,13 @@ ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GError **error)
goto out;
if (opt_refs_only)
pruneflags |= OSTREE_PRUNE_FLAGS_REFS_ONLY;
pruneflags |= OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY;
if (opt_no_prune)
pruneflags |= OSTREE_PRUNE_FLAGS_NO_PRUNE;
pruneflags |= OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE;
if (!ostree_prune (repo, pruneflags, opt_depth,
&n_objects_total, &n_objects_pruned, &objsize_total,
cancellable, error))
if (!ostree_repo_prune (repo, pruneflags, opt_depth,
&n_objects_total, &n_objects_pruned, &objsize_total,
cancellable, error))
goto out;
formatted_freed_size = g_format_size_full (objsize_total, 0);
@ -77,7 +77,7 @@ ostree_builtin_prune (int argc, char **argv, GFile *repo_path, GError **error)
g_print ("Total objects: %u\n", n_objects_total);
if (n_objects_pruned == 0)
g_print ("No unreachable objects\n");
else if (pruneflags & OSTREE_PRUNE_FLAGS_NO_PRUNE)
else if (pruneflags & OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE)
g_print ("Would delete: %u objects, freeing %s bytes\n",
n_objects_pruned, formatted_freed_size);
else