mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
prune: Don't fail if an object isn't found
We expect most people to have partial repositories.
This commit is contained in:
parent
9d58bad7ca
commit
e2aabce708
@ -149,6 +149,12 @@ gboolean ostree_repo_load_variant (OstreeRepo *self,
|
||||
GVariant **out_variant,
|
||||
GError **error);
|
||||
|
||||
gboolean ostree_repo_load_variant_if_exists (OstreeRepo *self,
|
||||
OstreeObjectType expected_type,
|
||||
const char *sha256,
|
||||
GVariant **out_variant,
|
||||
GError **error);
|
||||
|
||||
gboolean ostree_repo_load_pack_index (OstreeRepo *self,
|
||||
const char *pack_checksum,
|
||||
gboolean is_meta,
|
||||
|
@ -44,7 +44,7 @@ traverse_dirtree_internal (OstreeRepo *repo,
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int n, i;
|
||||
ot_lvariant GVariant *key;
|
||||
ot_lvariant GVariant *key = NULL;
|
||||
ot_lvariant GVariant *tree = NULL;
|
||||
ot_lvariant GVariant *files_variant = NULL;
|
||||
ot_lvariant GVariant *dirs_variant = NULL;
|
||||
@ -60,9 +60,12 @@ traverse_dirtree_internal (OstreeRepo *repo,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_DIR_TREE, dirtree_checksum, &tree, error))
|
||||
if (!ostree_repo_load_variant_if_exists (repo, OSTREE_OBJECT_TYPE_DIR_TREE, dirtree_checksum, &tree, error))
|
||||
goto out;
|
||||
|
||||
if (!tree)
|
||||
return TRUE;
|
||||
|
||||
key = ostree_object_name_serialize (dirtree_checksum, OSTREE_OBJECT_TYPE_DIR_TREE);
|
||||
if (!g_hash_table_lookup (inout_reachable, key))
|
||||
{
|
||||
@ -126,6 +129,12 @@ ostree_traverse_dirtree (OstreeRepo *repo,
|
||||
inout_reachable, cancellable, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_traverse_commit:
|
||||
*
|
||||
* Add to @inout_reachable all objects reachable from
|
||||
* @commit_checksum, traversing @maxdepth parent commits.
|
||||
*/
|
||||
gboolean
|
||||
ostree_traverse_commit (OstreeRepo *repo,
|
||||
const char *commit_checksum,
|
||||
@ -147,8 +156,14 @@ ostree_traverse_commit (OstreeRepo *repo,
|
||||
ot_lvariant GVariant *commit = NULL;
|
||||
|
||||
/* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */
|
||||
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, commit_checksum, &commit, error))
|
||||
if (!ostree_repo_load_variant_if_exists (repo, OSTREE_OBJECT_TYPE_COMMIT, commit_checksum, &commit, error))
|
||||
goto out;
|
||||
|
||||
/* Just return if the parent isn't found; we do expect most
|
||||
* people to have partial repositories.
|
||||
*/
|
||||
if (!commit)
|
||||
break;
|
||||
|
||||
key = ostree_object_name_serialize (commit_checksum, OSTREE_OBJECT_TYPE_COMMIT);
|
||||
g_hash_table_replace (inout_reachable, key, key);
|
||||
|
@ -93,7 +93,8 @@ prune_loose_object (OtPruneData *data,
|
||||
}
|
||||
else
|
||||
{
|
||||
g_print ("Unreachable: %s.%s\n", checksum, ostree_object_type_to_string (objtype));
|
||||
if (verbose)
|
||||
g_print ("Unreachable: %s.%s\n", checksum, ostree_object_type_to_string (objtype));
|
||||
}
|
||||
data->n_unreachable++;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user