lib: Add an API to list only "our" objects, fix prune to use it

When doing a prune, we should not try to delete objects in parent
repos, since it'll fail.  There is a bigger discussion about the
semantics of `parent=` to be had, but this will fix trying to use
`ostree prune --repo=/ostree/repo/extensions/rpmostree/pkgcache`.

Closes: https://github.com/ostreedev/ostree/issues/467

Closes: #471
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2016-08-25 20:01:37 +00:00
1 parent 683e060099
commit 3ef4cc2e5b
4 files changed
+43 -5

No files matched your search

+2 -2
View File
@@ -337,8 +337,8 @@ ostree_repo_prune (OstreeRepo *self,
}
}
if (!ostree_repo_list_objects (self, OSTREE_REPO_LIST_OBJECTS_ALL, &objects,
cancellable, error))
if (!ostree_repo_list_objects (self, OSTREE_REPO_LIST_OBJECTS_ALL | OSTREE_REPO_LIST_OBJECTS_NO_PARENTS,
&objects, cancellable, error))
goto out;
if (!refs_only)
+1 -1
View File
@@ -3590,7 +3590,7 @@ ostree_repo_list_objects (OstreeRepo *self,
{
if (!list_loose_objects (self, ret_objects, NULL, cancellable, error))
goto out;
if (self->parent_repo)
if ((flags & OSTREE_REPO_LIST_OBJECTS_NO_PARENTS) == 0 && self->parent_repo)
{
if (!list_loose_objects (self->parent_repo, ret_objects, NULL, cancellable, error))
goto out;
+3 -1
View File
@@ -798,11 +798,13 @@ gboolean ostree_repo_read_commit (OstreeRepo *self,
* @OSTREE_REPO_LIST_OBJECTS_LOOSE: List only loose (plain file) objects
* @OSTREE_REPO_LIST_OBJECTS_PACKED: List only packed (compacted into blobs) objects
* @OSTREE_REPO_LIST_OBJECTS_ALL: List all objects
* @OSTREE_REPO_LIST_OBJECTS_NO_PARENTS: Only list objects in this repo, not parents
*/
typedef enum {
OSTREE_REPO_LIST_OBJECTS_LOOSE = (1 << 0),
OSTREE_REPO_LIST_OBJECTS_PACKED = (1 << 1),
OSTREE_REPO_LIST_OBJECTS_ALL = (1 << 2)
OSTREE_REPO_LIST_OBJECTS_ALL = (1 << 2),
OSTREE_REPO_LIST_OBJECTS_NO_PARENTS = (1 << 3),
} OstreeRepoListObjectsFlags;
/**