mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-03 05:18:24 +03:00
lib/pull: Fix miscounting of missing metadata
If e.g. detached metadata or a parent commit is missing, we don't consider it an error but we erroneously still increment the `n_fetched_metadata` counter, causing it to be higher than it should. This will implicitly be tested by a test added in the next patch.
This commit is contained in:
parent
3c2587b619
commit
c8ed1c7a87
@ -1069,6 +1069,7 @@ meta_fetch_on_complete (GObject *object, GAsyncResult *result, gpointer user_dat
|
||||
g_autoptr (GError) local_error = NULL;
|
||||
GError **error = &local_error;
|
||||
gboolean free_fetch_data = TRUE;
|
||||
gboolean was_enoent = FALSE;
|
||||
|
||||
ostree_object_name_deserialize (fetch_data->object, &checksum, &objtype);
|
||||
checksum_obj = ostree_object_to_string (checksum, objtype);
|
||||
@ -1079,6 +1080,7 @@ meta_fetch_on_complete (GObject *object, GAsyncResult *result, gpointer user_dat
|
||||
{
|
||||
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
||||
{
|
||||
was_enoent = TRUE;
|
||||
if (fetch_data->is_detached_meta)
|
||||
{
|
||||
/* There isn't any detached metadata, just fetch the commit */
|
||||
@ -1195,7 +1197,7 @@ out:
|
||||
g_assert (pull_data->n_outstanding_metadata_fetches > 0);
|
||||
pull_data->n_outstanding_metadata_fetches--;
|
||||
|
||||
if (local_error == NULL)
|
||||
if (local_error == NULL && !was_enoent)
|
||||
pull_data->n_fetched_metadata++;
|
||||
|
||||
if (_ostree_fetcher_should_retry_request (local_error, fetch_data->n_retries_remaining--))
|
||||
|
@ -48,7 +48,7 @@ commit=$(${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo commit -b main --tree=
|
||||
rm -rf repo
|
||||
init_repo
|
||||
${CMD_PREFIX} ostree --repo=repo pull --localcache-repo repo-local origin main >out.txt
|
||||
assert_file_has_content out.txt '3 metadata, 1 content objects fetched (4 meta, 5 content local)'
|
||||
assert_file_has_content out.txt '2 metadata, 1 content objects fetched (4 meta, 5 content local)'
|
||||
echo "ok pull --localcache-repo"
|
||||
|
||||
# Check that pulling the same commit works as well
|
||||
|
Loading…
Reference in New Issue
Block a user