lib/pull: Don't fetch detached metadata twice for local pulls
authorColin Walters <walters@verbum.org>
Thu, 29 Jun 2017 02:23:17 +0000 (22:23 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 29 Jun 2017 15:48:59 +0000 (15:48 +0000)
Obviously very minor, but I noticed this while working on `pull --reference`. If
we have a local repo, we'll have already done a hardlink and copied the detached
metadata too, so there's no reason to request it again via the fetcher path.

Closes: #978
Approved by: jlebon

src/libostree/ostree-repo-pull.c

index a82448e13ec93b538c21691b7a81ce3c46cc56e8..31c825b80d7fc295c34484b10ef9f59748386540 100644 (file)
@@ -1514,6 +1514,11 @@ scan_one_metadata_object_c (OtPullData         *pull_data,
                                                           objtype, tmp_checksum, !pull_data->is_untrusted,
                                                           cancellable, error))
             return FALSE;
+          /* The import API will fetch both the commit and detached metadata, so
+           * add it to the hash to avoid re-fetching it below.
+           */
+          if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
+            g_hash_table_add (pull_data->fetched_detached_metadata, g_strdup (tmp_checksum));
         }
       is_stored = TRUE;
       is_requested = TRUE;