Skip to content

Commit

Permalink
Merge pull request #2632 from saqibali-2k/pr/prune-commit-only
Browse files Browse the repository at this point in the history
lib/prune: speed up pruning by retrieving only commits
  • Loading branch information
cgwalters authored Jun 30, 2022
2 parents e527cdc + a984871 commit 0d911bf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
29 changes: 24 additions & 5 deletions src/libostree/ostree-repo-prune.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ _ostree_repo_prune_tmp (OstreeRepo *self,
return TRUE;
}


/**
* ostree_repo_prune_static_deltas:
* @self: Repo
Expand Down Expand Up @@ -437,8 +436,17 @@ ostree_repo_prune (OstreeRepo *self,
return FALSE;
}

objects = ostree_repo_list_objects_set (self, OSTREE_REPO_LIST_OBJECTS_ALL | OSTREE_REPO_LIST_OBJECTS_NO_PARENTS,
if (commit_only)
{
if (!ostree_repo_list_commit_objects_starting_with (self, "", &objects, cancellable, error))
return FALSE;
}
else
{
objects = ostree_repo_list_objects_set (self, OSTREE_REPO_LIST_OBJECTS_ALL | OSTREE_REPO_LIST_OBJECTS_NO_PARENTS,
cancellable, error);
}

if (!objects)
return FALSE;

Expand Down Expand Up @@ -508,9 +516,20 @@ ostree_repo_prune_from_reachable (OstreeRepo *self,
if (!lock)
return FALSE;

g_autoptr(GHashTable) objects =
ostree_repo_list_objects_set (self, OSTREE_REPO_LIST_OBJECTS_ALL | OSTREE_REPO_LIST_OBJECTS_NO_PARENTS,
cancellable, error);
g_autoptr(GHashTable) objects = NULL;
OstreeRepoPruneFlags flags = options->flags;
gboolean commit_only = (flags & OSTREE_REPO_PRUNE_FLAGS_COMMIT_ONLY) > 0;
if (commit_only)
{
if (!ostree_repo_list_commit_objects_starting_with (self, "", &objects, cancellable, error))
return FALSE;
}
else
{
objects =
ostree_repo_list_objects_set (self, OSTREE_REPO_LIST_OBJECTS_ALL | OSTREE_REPO_LIST_OBJECTS_NO_PARENTS,
cancellable, error);
}
if (!objects)
return FALSE;

Expand Down
2 changes: 1 addition & 1 deletion src/libostree/ostree-repo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ void ostree_repo_commit_traverse_iter_cleanup (void *p);
* OstreeRepoPruneFlags:
* @OSTREE_REPO_PRUNE_FLAGS_NONE: No special options for pruning
* @OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE: Don't actually delete objects
* @OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY: Do not traverse individual commit objects, only follow refs
* @OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY: Do not traverse individual commit objects, only follow refs for reachability calculations
* @OSTREE_REPO_PRUNE_FLAGS_COMMIT_ONLY: Only traverse commit objects. (Since 2022.2)
*/
typedef enum {
Expand Down

0 comments on commit 0d911bf

Please sign in to comment.