[ostree] prune: add new flag --static-deltas-only



commit 44c6197b0a78f651658b7b17bf6eecd0aaa541da
Author: Giuseppe Scrivano <gscrivan redhat com>
Date:   Tue Dec 15 11:32:05 2015 +0100

    prune: add new flag --static-deltas-only
    
    When specified, only the static deltas files are pruned.
    
    Signed-off-by: Giuseppe Scrivano <gscrivan redhat com>

 doc/ostree-prune.xml          |    9 +++++++++
 src/ostree/ot-builtin-prune.c |   23 +++++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/doc/ostree-prune.xml b/doc/ostree-prune.xml
index 03d7fc5..9e8cc87 100644
--- a/doc/ostree-prune.xml
+++ b/doc/ostree-prune.xml
@@ -104,6 +104,15 @@ Boston, MA 02111-1307, USA.
                     Only traverse DEPTH (integer) parents for each commit (default: -1=infinite).
                 </para></listitem>
             </varlistentry>
+
+            <varlistentry>
+                <term><option>--static-deltas-only</option>=DEPTH</term>
+
+                <listitem><para>
+                  Change the behaviour of --keep-younger-than and --delete-commit to prune only
+                  the static deltas files.
+                </para></listitem>
+            </varlistentry>
         </variablelist>
     </refsect1>
 
diff --git a/src/ostree/ot-builtin-prune.c b/src/ostree/ot-builtin-prune.c
index 104736e..0b843c9 100644
--- a/src/ostree/ot-builtin-prune.c
+++ b/src/ostree/ot-builtin-prune.c
@@ -29,6 +29,7 @@
 #include "parse-datetime.h"
 
 static gboolean opt_no_prune;
+static gboolean opt_static_deltas_only;
 static gint opt_depth = -1;
 static gboolean opt_refs_only;
 static char *opt_delete_commit;
@@ -40,6 +41,7 @@ static GOptionEntry options[] = {
   { "depth", 0, 0, G_OPTION_ARG_INT, &opt_depth, "Only traverse DEPTH parents for each commit (default: 
-1=infinite)", "DEPTH" },
   { "delete-commit", 0, 0, G_OPTION_ARG_STRING, &opt_delete_commit, "Specify a commit to delete", "COMMIT" },
   { "keep-younger-than", 0, 0, G_OPTION_ARG_STRING, &opt_keep_younger_than, "Prune all commits older than 
the specified date", "DATE" },
+  { "static-deltas-only", 0, 0, G_OPTION_ARG_NONE, &opt_static_deltas_only, "Change the behavior of 
delete-commit and keep-younger-than to prune only static deltas" },
   { NULL }
 };
 
@@ -124,8 +126,16 @@ prune_commits_keep_younger_than_date (OstreeRepo *repo, const char *date, GCance
       commit_timestamp = ostree_commit_get_timestamp (commit);
       if (commit_timestamp < ts.tv_sec)
         {
-          if (!ostree_repo_delete_object (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum, cancellable, error))
-            goto out;
+          if (opt_static_deltas_only)
+            {
+              if(!ostree_repo_prune_static_deltas (repo, checksum, cancellable, error))
+                goto out;
+            }
+          else
+            {
+              if (!ostree_repo_delete_object (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum, cancellable, error))
+                goto out;
+            }
         }
     }
 
@@ -162,8 +172,13 @@ ostree_builtin_prune (int argc, char **argv, GCancellable *cancellable, GError *
           ot_util_usage_error (context, "Cannot specify both --delete-commit and --no-prune", error);
           goto out;
         }
-      if (!delete_commit (repo, opt_delete_commit, cancellable, error))
-        goto out;
+        if (opt_static_deltas_only)
+          {
+            if(!ostree_repo_prune_static_deltas (repo, opt_delete_commit, cancellable, error))
+              goto out;
+          }
+        else if (!delete_commit (repo, opt_delete_commit, cancellable, error))
+          goto out;
     }
   if (opt_keep_younger_than)
     {


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