lib/pull: Minor refactoring of metadata scanning function

Make the "local repo" processing conditional the same as the "localcache" bits;
this is really just a de-indent. Also add some comments. Prep for further work.

Closes: #1212
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-09-23 09:44:49 -04:00 committed by Atomic Bot
parent d0d27288da
commit 72ddd4f419
1 changed files with 17 additions and 16 deletions

View File

@ -1749,18 +1749,20 @@ scan_one_metadata_object_c (OtPullData *pull_data,
g_autofree char *tmp_checksum = ostree_checksum_from_bytes (csum); g_autofree char *tmp_checksum = ostree_checksum_from_bytes (csum);
g_autoptr(GVariant) object = ostree_object_name_serialize (tmp_checksum, objtype); g_autoptr(GVariant) object = ostree_object_name_serialize (tmp_checksum, objtype);
/* It may happen that we've already looked at this object (think shared
* dirtree subtrees), if that's the case, we're done */
if (g_hash_table_lookup (pull_data->scanned_metadata, object)) if (g_hash_table_lookup (pull_data->scanned_metadata, object))
return TRUE; return TRUE;
gboolean is_requested = g_hash_table_lookup (pull_data->requested_metadata, object) != NULL; gboolean is_requested = g_hash_table_lookup (pull_data->requested_metadata, object) != NULL;
/* Determine if we already have the object */
gboolean is_stored; gboolean is_stored;
if (!ostree_repo_has_object (pull_data->repo, objtype, tmp_checksum, &is_stored, if (!ostree_repo_has_object (pull_data->repo, objtype, tmp_checksum, &is_stored,
cancellable, error)) cancellable, error))
return FALSE; return FALSE;
if (pull_data->remote_repo_local) /* Are we pulling an object we don't have from a local repo? */
{ if (!is_stored && pull_data->remote_repo_local)
if (!is_stored)
{ {
if (objtype == OSTREE_OBJECT_TYPE_COMMIT) if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
{ {
@ -1777,7 +1779,6 @@ scan_one_metadata_object_c (OtPullData *pull_data,
*/ */
if (objtype == OSTREE_OBJECT_TYPE_COMMIT) if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
g_hash_table_add (pull_data->fetched_detached_metadata, g_strdup (tmp_checksum)); g_hash_table_add (pull_data->fetched_detached_metadata, g_strdup (tmp_checksum));
}
is_stored = TRUE; is_stored = TRUE;
is_requested = TRUE; is_requested = TRUE;
} }