diff --git a/src/libostree/ostree-repo-prune.c b/src/libostree/ostree-repo-prune.c index fc3cfa548e..9d89b26100 100644 --- a/src/libostree/ostree-repo-prune.c +++ b/src/libostree/ostree-repo-prune.c @@ -58,6 +58,21 @@ maybe_prune_loose_object (OtPruneData *data, { guint64 storage_size = 0; + if (objtype == OSTREE_OBJECT_TYPE_PAYLOAD_LINK) + { + char loose_path_buf[_OSTREE_LOOSE_PATH_MAX]; + char target_checksum[OSTREE_SHA256_STRING_LEN+1]; + + _ostree_loose_path (loose_path_buf, checksum, OSTREE_OBJECT_TYPE_PAYLOAD_LINK, data->repo->mode); + if (readlinkat (data->repo->objects_dir_fd, loose_path_buf, target_checksum, sizeof (target_checksum)) < 0) + return glnx_throw_errno (error); + + g_autoptr(GVariant) target_key = NULL; + target_key = ostree_object_name_serialize (target_checksum, OSTREE_OBJECT_TYPE_FILE); + + if (g_hash_table_lookup_extended (data->reachable, target_key, NULL, NULL)) + return TRUE; + } if (objtype == OSTREE_OBJECT_TYPE_COMMIT) { if (!ostree_repo_mark_commit_partial (data->repo, checksum, FALSE, error)) @@ -233,6 +248,7 @@ repo_prune_internal (OstreeRepo *self, g_autoptr(GHashTable) reachable_owned = g_hash_table_ref (options->reachable); data.reachable = reachable_owned; + GLNX_HASH_TABLE_FOREACH_KV (objects, GVariant*, serialized_key, GVariant*, objdata) { const char *checksum; @@ -283,7 +299,7 @@ repo_prune_internal (OstreeRepo *self, * of traversing all commits, only refs will be used. Particularly * when combined with @depth, this is a convenient way to delete * history from the repository. - * + * * Use the %OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE to just determine * statistics on objects that would be deleted, without actually * deleting them.