_ostree_static_delta_part_validate: Take a stream instead of a file as arg
authorAlexander Larsson <alexl@redhat.com>
Thu, 10 Sep 2015 18:16:52 +0000 (20:16 +0200)
committerColin Walters <walters@verbum.org>
Mon, 14 Sep 2015 02:25:21 +0000 (22:25 -0400)
This is only called in one place, and we have already opened the file there,
no need to open it twice.

src/libostree/ostree-repo-static-delta-core.c
src/libostree/ostree-repo-static-delta-private.h
src/libostree/ostree-repo-static-delta-processing.c

index cd2940baae7e2d98a8a9bb408f5c6b39d8dba5f3..c58f868ae41b06efbca8f837be154dda339a18c0 100644 (file)
@@ -318,7 +318,7 @@ ostree_repo_static_delta_execute_offline (OstreeRepo                    *self,
       if (!skip_validation)
         {
           g_autofree char *expected_checksum = ostree_checksum_from_bytes (csum);
-          if (!_ostree_static_delta_part_validate (self, part_path, i,
+          if (!_ostree_static_delta_part_validate (self, in, i,
                                                    expected_checksum,
                                                    cancellable, error))
             goto out;
index 4df3b8c684e5bda023c0d31b7bfe2859917c7ed7..7dfba0a90fd6d8a5ef66ecfc8c68d568c858387c 100644 (file)
@@ -104,7 +104,7 @@ G_BEGIN_DECLS
 #define OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT "(a{sv}tayay" OSTREE_COMMIT_GVARIANT_STRING "aya" OSTREE_STATIC_DELTA_META_ENTRY_FORMAT "a" OSTREE_STATIC_DELTA_FALLBACK_FORMAT ")"
 
 gboolean _ostree_static_delta_part_validate (OstreeRepo     *repo,
-                                             GFile          *part_path,
+                                             GInputStream   *in,
                                              guint           part_offset,
                                              const char     *expected_checksum,
                                              GCancellable   *cancellable,
index 1f2b3262bca4fa0ad4402b0cc3857a67bc6400e0..18687f8a3543a5ec19f80ebcdbb85d2ff6ac686a 100644 (file)
@@ -150,22 +150,17 @@ open_output_target (StaticDeltaExecutionState   *state,
 
 gboolean
 _ostree_static_delta_part_validate (OstreeRepo     *repo,
-                                    GFile          *part_path,
+                                    GInputStream   *in,
                                     guint           part_offset,
                                     const char     *expected_checksum,
                                     GCancellable   *cancellable,
                                     GError        **error)
 {
   gboolean ret = FALSE;
-  g_autoptr(GInputStream) tmp_in = NULL;
   g_autofree guchar *actual_checksum_bytes = NULL;
   g_autofree char *actual_checksum = NULL;
   
-  tmp_in = (GInputStream*)g_file_read (part_path, cancellable, error);
-  if (!tmp_in)
-    goto out;
-  
-  if (!ot_gio_checksum_stream (tmp_in, &actual_checksum_bytes,
+  if (!ot_gio_checksum_stream (in, &actual_checksum_bytes,
                                cancellable, error))
     goto out;