[ostree/wip/delta-continuation: 2/7] Flesh out delta part HTTP fetch a bit more



commit c786f3d248e1cddc11a33ccc149e8b7e9cb2e299
Author: Colin Walters <walters verbum org>
Date:   Thu Apr 3 09:10:59 2014 -0400

    Flesh out delta part HTTP fetch a bit more

 src/libostree/ostree-repo-pull.c                 |   41 +++++++++++++++++++---
 src/libostree/ostree-repo-static-delta-core.c    |   15 ++++----
 src/libostree/ostree-repo-static-delta-private.h |    7 ++++
 3 files changed, 51 insertions(+), 12 deletions(-)
---
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
index 56db7c4..756a1cf 100644
--- a/src/libostree/ostree-repo-pull.c
+++ b/src/libostree/ostree-repo-pull.c
@@ -60,6 +60,8 @@ typedef struct {
   guint             n_outstanding_metadata_write_requests;
   guint             n_outstanding_content_fetches;
   guint             n_outstanding_content_write_requests;
+  guint             n_outstanding_deltapart_fetches;
+  guint             n_outstanding_deltapart_write_requests;
   gint              n_requested_metadata;
   gint              n_requested_content;
   guint             n_fetched_metadata;
@@ -136,9 +138,11 @@ update_progress (gpointer user_data)
 {
   OtPullData *pull_data = user_data;
   guint outstanding_writes = pull_data->n_outstanding_content_write_requests +
-    pull_data->n_outstanding_metadata_write_requests;
+    pull_data->n_outstanding_metadata_write_requests +
+    pull_data->n_outstanding_deltapart_write_requests;
   guint outstanding_fetches = pull_data->n_outstanding_content_fetches +
-    pull_data->n_outstanding_metadata_fetches;
+    pull_data->n_outstanding_metadata_fetches +
+    pull_data->n_outstanding_deltapart_fetches;
   guint64 bytes_transferred = ostree_fetcher_bytes_transferred (pull_data->fetcher);
   guint fetched = pull_data->n_fetched_metadata + pull_data->n_fetched_content;
   guint requested = pull_data->n_requested_metadata + pull_data->n_requested_content;
@@ -189,9 +193,11 @@ check_outstanding_requests_handle_error (OtPullData          *pull_data,
                                          GError              *error)
 {
   gboolean current_fetch_idle = (pull_data->n_outstanding_metadata_fetches == 0 &&
-                                 pull_data->n_outstanding_content_fetches == 0);
+                                 pull_data->n_outstanding_content_fetches == 0 &&
+                                 pull_data->n_outstanding_deltapart_fetches == 0);
   gboolean current_write_idle = (pull_data->n_outstanding_metadata_write_requests == 0 &&
-                                 pull_data->n_outstanding_content_write_requests == 0);
+                                 pull_data->n_outstanding_content_write_requests == 0 &&
+                                 pull_data->n_outstanding_deltapart_write_requests == 0 );
   gboolean current_idle = current_fetch_idle && current_write_idle;
 
   throw_async_error (pull_data, error);
@@ -1086,6 +1092,9 @@ process_one_static_delta (OtPullData   *pull_data,
     {
       const guchar *csum;
       gs_unref_variant GVariant *header = NULL;
+      gboolean have_all = FALSE;
+      SoupURI *target_uri = NULL;
+      gs_free char *deltapart_path = NULL;
 
       header = g_variant_get_child_value (headers, i);
       g_variant_get (header, "(@aytt ay)", &csum_v, &size, &usize, &objects);
@@ -1094,7 +1103,29 @@ process_one_static_delta (OtPullData   *pull_data,
       if (!csum)
         goto out;
 
-      part_path = ot_gfile_resolve_path_printf (dir, "%u", i);
+      if (!_ostree_repo_static_delta_part_have_all_objects (self,
+                                                            objects,
+                                                            &have_all,
+                                                            cancellable, error))
+        goto out;
+
+      if (have_all)
+        {
+          g_debug ("Have all objects from static delta %s-%s part %u",
+                   from_revision, to_revision,
+                   i);
+          continue;
+        }
+
+      deltapart_path = _ostree_get_relative_static_delta_part_path (from_revision,
+                                                                    to_revision,
+                                                                    i);
+
+      target_uri = suburi_new (pull_data->base_uri, deltapart_path, NULL);
+      ostree_fetcher_request_uri_with_partial_async (pull_data->fetcher, target_uri, pull_data->cancellable,
+                                                     static_deltapart_fetch_on_complete,
+                                                     pull_data);
+      soup_uri_free (obj_uri);
     }
 }
 
diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c
index e29c75c..92174f3 100644
--- a/src/libostree/ostree-repo-static-delta-core.c
+++ b/src/libostree/ostree-repo-static-delta-core.c
@@ -115,12 +115,12 @@ ostree_repo_list_static_delta_names (OstreeRepo                  *self,
   return ret;
 }
 
-static gboolean
-have_all_objects (OstreeRepo             *repo,
-                  GVariant               *checksum_array,
-                  gboolean               *out_have_all,
-                  GCancellable           *cancellable,
-                  GError                **error)
+gboolean
+_ostree_repo_static_delta_part_have_all_objects (OstreeRepo             *repo,
+                                                 GVariant               *checksum_array,
+                                                 gboolean               *out_have_all,
+                                                 GCancellable           *cancellable,
+                                                 GError                **error)
 {
   gboolean ret = FALSE;
   guint8 *checksums_data;
@@ -234,7 +234,8 @@ ostree_repo_static_delta_execute_offline (OstreeRepo                    *self,
       header = g_variant_get_child_value (headers, i);
       g_variant_get (header, "(@aytt ay)", &csum_v, &size, &usize, &objects);
 
-      if (!have_all_objects (self, objects, &have_all, cancellable, error))
+      if (!_ostree_repo_static_delta_part_have_all_objects (self, objects, &have_all,
+                                                            cancellable, error))
         goto out;
 
       /* If we already have these objects, don't bother executing the
diff --git a/src/libostree/ostree-repo-static-delta-private.h 
b/src/libostree/ostree-repo-static-delta-private.h
index 3855288..37a3a90 100644
--- a/src/libostree/ostree-repo-static-delta-private.h
+++ b/src/libostree/ostree-repo-static-delta-private.h
@@ -93,5 +93,12 @@ _ostree_static_delta_parse_checksum_array (GVariant      *array,
                                            guint8       **out_checksums_array,
                                            guint         *out_n_checksums,
                                            GError       **error);
+
+gboolean
+_ostree_repo_static_delta_part_have_all_objects (OstreeRepo             *repo,
+                                                 GVariant               *checksum_array,
+                                                 gboolean               *out_have_all,
+                                                 GCancellable           *cancellable,
+                                                 GError                **error);
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]