[ostree] static-delta: Don't run bspatch when output object already exists



commit f2b4a9e10729321d7fd90382cda28d450479b336
Author: John Hiesey <john hiesey com>
Date:   Wed Oct 7 14:43:13 2015 -0700

    static-delta: Don't run bspatch when output object already exists
    
    There is already a check that the destination object does not
    exist in all other cases when processing an incoming static delta.
    However, the bspatch case would still try to run and fail. Add
    an analogous check to that case as well.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756260

 .../ostree-repo-static-delta-processing.c          |   49 ++++++++++---------
 1 files changed, 26 insertions(+), 23 deletions(-)
---
diff --git a/src/libostree/ostree-repo-static-delta-processing.c 
b/src/libostree/ostree-repo-static-delta-processing.c
index 18687f8..f60ec7a 100644
--- a/src/libostree/ostree-repo-static-delta-processing.c
+++ b/src/libostree/ostree-repo-static-delta-processing.c
@@ -530,32 +530,35 @@ dispatch_bspatch (OstreeRepo                 *repo,
   if (!read_varuint64 (state, &length, error))
     goto out;
 
-  input_mfile = g_mapped_file_new_from_fd (state->read_source_fd, FALSE, error);
-  if (!input_mfile)
-    goto out;
+  if (!state->have_obj)
+    {
+      input_mfile = g_mapped_file_new_from_fd (state->read_source_fd, FALSE, error);
+      if (!input_mfile)
+        goto out;
 
-  buf = g_malloc0 (state->content_size);
-
-  opaque.state = state;
-  opaque.offset = offset;
-  opaque.length = length;
-  stream.read = bspatch_read;
-  stream.opaque = &opaque;
-  if (bspatch ((const guint8*)g_mapped_file_get_contents (input_mfile),
-               g_mapped_file_get_length (input_mfile),
-               buf,
-               state->content_size,
-               &stream) < 0)
-    goto out;
+      buf = g_malloc0 (state->content_size);
+
+      opaque.state = state;
+      opaque.offset = offset;
+      opaque.length = length;
+      stream.read = bspatch_read;
+      stream.opaque = &opaque;
+      if (bspatch ((const guint8*)g_mapped_file_get_contents (input_mfile),
+                   g_mapped_file_get_length (input_mfile),
+                   buf,
+                   state->content_size,
+                   &stream) < 0)
+        goto out;
 
-  if (!g_output_stream_write_all (state->content_out,
-                                  buf,
-                                  state->content_size,
-                                  &bytes_written,
-                                  cancellable, error))
-    goto out;
+      if (!g_output_stream_write_all (state->content_out,
+                                      buf,
+                                      state->content_size,
+                                      &bytes_written,
+                                      cancellable, error))
+        goto out;
 
-  g_assert (bytes_written == state->content_size);
+      g_assert (bytes_written == state->content_size);
+    }
 
   ret = TRUE;
  out:


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