mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-09 01:18:35 +03:00
lib/repo: Do account for size with prune --no-prune
I think this got changed in a refactor. We definitely want to total up the amount of space that *would* be freed even with `--no-prune` AKA `OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE`. It's actually a bit terrifying this is apparently the first test case for the `--no-prune` option... Closes: https://github.com/ostreedev/ostree/issues/1480 Closes: #1483 Approved by: jlebon
This commit is contained in:
parent
1214395f0e
commit
733c0498dc
@ -51,29 +51,32 @@ maybe_prune_loose_object (OtPruneData *data,
|
|||||||
key = ostree_object_name_serialize (checksum, objtype);
|
key = ostree_object_name_serialize (checksum, objtype);
|
||||||
|
|
||||||
if (!g_hash_table_lookup_extended (data->reachable, key, NULL, NULL))
|
if (!g_hash_table_lookup_extended (data->reachable, key, NULL, NULL))
|
||||||
{
|
|
||||||
g_debug ("Pruning unneeded object %s.%s", checksum,
|
|
||||||
ostree_object_type_to_string (objtype));
|
|
||||||
if (!(flags & OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE))
|
|
||||||
{
|
{
|
||||||
guint64 storage_size = 0;
|
guint64 storage_size = 0;
|
||||||
|
|
||||||
|
g_debug ("Pruning unneeded object %s.%s", checksum,
|
||||||
|
ostree_object_type_to_string (objtype));
|
||||||
|
|
||||||
|
if (!ostree_repo_query_object_storage_size (data->repo, objtype, checksum,
|
||||||
|
&storage_size, cancellable, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
data->freed_bytes += storage_size;
|
||||||
|
|
||||||
|
if (!(flags & OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE))
|
||||||
|
{
|
||||||
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
|
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
|
||||||
{
|
{
|
||||||
if (!ostree_repo_mark_commit_partial (data->repo, checksum, FALSE, error))
|
if (!ostree_repo_mark_commit_partial (data->repo, checksum, FALSE, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ostree_repo_query_object_storage_size (data->repo, objtype, checksum,
|
|
||||||
&storage_size, cancellable, error))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (!ostree_repo_delete_object (data->repo, objtype, checksum,
|
if (!ostree_repo_delete_object (data->repo, objtype, checksum,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
data->freed_bytes += storage_size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OSTREE_OBJECT_TYPE_IS_META (objtype))
|
if (OSTREE_OBJECT_TYPE_IS_META (objtype))
|
||||||
data->n_unreachable_meta++;
|
data->n_unreachable_meta++;
|
||||||
else
|
else
|
||||||
|
@ -52,6 +52,13 @@ assert_repo_has_n_commits() {
|
|||||||
assert_streq "$(find ${repo}/objects -name '*.commit' | wc -l)" "${count}"
|
assert_streq "$(find ${repo}/objects -name '*.commit' | wc -l)" "${count}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Test --no-prune
|
||||||
|
objectcount_orig=$(find repo/objects | wc -l)
|
||||||
|
${CMD_PREFIX} ostree prune --repo=repo --refs-only --depth=0 --no-prune | tee noprune.txt
|
||||||
|
assert_file_has_content noprune.txt 'Would delete: [1-9][0-9]* objects, freeing [1-9][0-9]*'
|
||||||
|
objectcount_new=$(find repo/objects | wc -l)
|
||||||
|
assert_streq "${objectcount_orig}" "${objectcount_new}"
|
||||||
|
|
||||||
${CMD_PREFIX} ostree prune --repo=repo --refs-only --depth=2 -v
|
${CMD_PREFIX} ostree prune --repo=repo --refs-only --depth=2 -v
|
||||||
assert_repo_has_n_commits repo 3
|
assert_repo_has_n_commits repo 3
|
||||||
find repo/objects -name '*.tombstone-commit' | wc -l > tombstonecommitcount
|
find repo/objects -name '*.tombstone-commit' | wc -l > tombstonecommitcount
|
||||||
|
Loading…
Reference in New Issue
Block a user