diff options
author | Philip Withnall <withnall@endlessm.com> | 2018-05-22 12:19:15 +0100 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-05-25 13:12:33 +0000 |
commit | dc1fde704da768e7dc5ab73a91e3892a6e576cf3 (patch) | |
tree | 708249f11c91584355fe5dae86528e443fffc1f1 | |
parent | 8b8952ebee1824162f3f282fbab0af54b1cf1eb4 (diff) | |
download | ostree-dc1fde704da768e7dc5ab73a91e3892a6e576cf3.tar.gz |
lib/repo-pull: Factor out enqueue function for FetchObjectData
This introduces no functional changes, but will make upcoming support
for retrying downloads easier to add.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1599
Approved by: jlebon
-rw-r--r-- | src/libostree/ostree-repo-pull.c | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index 87dd322d..b9cafa9d 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -224,6 +224,9 @@ static void queue_scan_one_metadata_object_c (OtPullData *pull_da guint recursion_depth, const OstreeCollectionRef *ref); +static void enqueue_one_object_request_s (OtPullData *pull_data, + FetchObjectData *fetch_data); + static gboolean scan_one_metadata_object (OtPullData *pull_data, const char *checksum, OstreeObjectType objtype, @@ -1917,31 +1920,14 @@ scan_one_metadata_object (OtPullData *pull_data, } static void -enqueue_one_object_request (OtPullData *pull_data, - const char *checksum, - OstreeObjectType objtype, - const char *path, - gboolean is_detached_meta, - gboolean object_is_stored, - const OstreeCollectionRef *ref) +enqueue_one_object_request_s (OtPullData *pull_data, + FetchObjectData *fetch_data) { - gboolean is_meta; - FetchObjectData *fetch_data; - - is_meta = OSTREE_OBJECT_TYPE_IS_META (objtype); - - fetch_data = g_new0 (FetchObjectData, 1); - fetch_data->pull_data = pull_data; - fetch_data->object = ostree_object_name_serialize (checksum, objtype); - fetch_data->path = g_strdup (path); - fetch_data->is_detached_meta = is_detached_meta; - fetch_data->object_is_stored = object_is_stored; - fetch_data->requested_ref = (ref != NULL) ? ostree_collection_ref_dup (ref) : NULL; + const char *checksum; + OstreeObjectType objtype; - if (is_meta) - pull_data->n_requested_metadata++; - else - pull_data->n_requested_content++; + ostree_object_name_deserialize (fetch_data->object, &checksum, &objtype); + gboolean is_meta = OSTREE_OBJECT_TYPE_IS_META (objtype); /* Are too many requests are in flight? */ if (fetcher_queue_is_full (pull_data)) @@ -1966,6 +1952,35 @@ enqueue_one_object_request (OtPullData *pull_data, } static void +enqueue_one_object_request (OtPullData *pull_data, + const char *checksum, + OstreeObjectType objtype, + const char *path, + gboolean is_detached_meta, + gboolean object_is_stored, + const OstreeCollectionRef *ref) +{ + FetchObjectData *fetch_data; + + fetch_data = g_new0 (FetchObjectData, 1); + fetch_data->pull_data = pull_data; + fetch_data->object = ostree_object_name_serialize (checksum, objtype); + fetch_data->path = g_strdup (path); + fetch_data->is_detached_meta = is_detached_meta; + fetch_data->object_is_stored = object_is_stored; + fetch_data->requested_ref = (ref != NULL) ? ostree_collection_ref_dup (ref) : NULL; + + gboolean is_meta = OSTREE_OBJECT_TYPE_IS_META (objtype); + + if (is_meta) + pull_data->n_requested_metadata++; + else + pull_data->n_requested_content++; + + enqueue_one_object_request_s (pull_data, g_steal_pointer (&fetch_data)); +} + +static void start_fetch (OtPullData *pull_data, FetchObjectData *fetch) { |