[ostree] libostree: Move prune into OstreeRepo namespace



commit 5dd0d5da40b7f2c2172f9d63d0da4d20b0fe9ec1
Author: Colin Walters <walters verbum org>
Date:   Tue Jul 9 20:05:31 2013 -0400

    libostree: Move prune into OstreeRepo namespace
    
    More library work.

 Makefile-libostree.am                              |    1 +
 Makefile-ostree.am                                 |    2 -
 .../ostree-repo-prune.c}                           |   26 ++++++------
 src/libostree/ostree-repo.h                        |   14 ++++++
 src/ostree/ostree-prune.h                          |   43 --------------------
 src/ostree/ot-admin-cleanup.c                      |    9 ++--
 src/ostree/ot-admin-functions.c                    |    3 +-
 src/ostree/ot-builtin-prune.c                      |   16 ++++----
 8 files changed, 41 insertions(+), 73 deletions(-)
---
diff --git a/Makefile-libostree.am b/Makefile-libostree.am
index 3de3469..3e5bce6 100644
--- a/Makefile-libostree.am
+++ b/Makefile-libostree.am
@@ -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 \
diff --git a/Makefile-ostree.am b/Makefile-ostree.am
index 3962104..8083bf2 100644
--- a/Makefile-ostree.am
+++ b/Makefile-ostree.am
@@ -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 \
diff --git a/src/ostree/ostree-prune.c b/src/libostree/ostree-repo-prune.c
similarity index 88%
rename from src/ostree/ostree-prune.c
rename to src/libostree/ostree-repo-prune.c
index 741e6b8..0f173d5 100644
--- a/src/ostree/ostree-prune.c
+++ b/src/libostree/ostree-repo-prune.c
@@ -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));
 
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index 8b5b55b..998bf43 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -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
 
diff --git a/src/ostree/ot-admin-cleanup.c b/src/ostree/ot-admin-cleanup.c
index 1ca242a..d8d9e8e 100644
--- a/src/ostree/ot-admin-cleanup.c
+++ b/src/ostree/ot-admin-cleanup.c
@@ -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)
     {
diff --git a/src/ostree/ot-admin-functions.c b/src/ostree/ot-admin-functions.c
index 1b469eb..3780c2a 100644
--- a/src/ostree/ot-admin-functions.c
+++ b/src/ostree/ot-admin-functions.c
@@ -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 *
diff --git a/src/ostree/ot-builtin-prune.c b/src/ostree/ot-builtin-prune.c
index f52153c..3c0a68c 100644
--- a/src/ostree/ot-builtin-prune.c
+++ b/src/ostree/ot-builtin-prune.c
@@ -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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]