From: Giuseppe Scrivano Date: Tue, 15 Dec 2015 10:32:05 +0000 (+0100) Subject: prune: add new flag --static-deltas-only X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~529 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=44c6197b0a78f651658b7b17bf6eecd0aaa541da;p=ostree.git prune: add new flag --static-deltas-only When specified, only the static deltas files are pruned. Signed-off-by: Giuseppe Scrivano --- diff --git a/doc/ostree-prune.xml b/doc/ostree-prune.xml index 03d7fc5c..9e8cc873 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). + + + =DEPTH + + + Change the behaviour of --keep-younger-than and --delete-commit to prune only + the static deltas files. + + diff --git a/src/ostree/ot-builtin-prune.c b/src/ostree/ot-builtin-prune.c index 104736ec..0b843c98 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) {