Skip to content

Commit

Permalink
lib/deltas: Move variant read helper into the deltas code
Browse files Browse the repository at this point in the history
What the deltas code is doing is weird/unfortunate.  The name
`ot_variant_read()` conflicts too much with `ot_variant_read_fd()`.
Since nothing else uses it, move it into the deltas code.

Closes: #1254
Approved by: jlebon
  • Loading branch information
cgwalters authored and rh-atomic-bot committed Oct 5, 2017
1 parent a903f96 commit fc33ae0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
17 changes: 15 additions & 2 deletions src/libostree/ostree-repo-static-delta-compilation.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,19 @@ get_fallback_headers (OstreeRepo *self,
return TRUE;
}

/* Get an input stream for a GVariant */
static GInputStream *
variant_to_inputstream (GVariant *variant)
{
GMemoryInputStream *ret = (GMemoryInputStream*)
g_memory_input_stream_new_from_data (g_variant_get_data (variant),
g_variant_get_size (variant),
NULL);
g_object_set_data_full ((GObject*)ret, "ot-variant-data",
g_variant_ref (variant), (GDestroyNotify) g_variant_unref);
return (GInputStream*)ret;
}

/**
* ostree_repo_static_delta_generate:
* @self: Repo
Expand Down Expand Up @@ -1349,7 +1362,7 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
/* Hardcode xz for now */
compressor = (GConverter*)_ostree_lzma_compressor_new (NULL);
compression_type_char = 'x';
part_payload_in = ot_variant_read (delta_part_content);
part_payload_in = variant_to_inputstream (delta_part_content);
part_payload_out = (GMemoryOutputStream*)g_memory_output_stream_new (NULL, 0, g_realloc, g_free);
part_payload_compressor = (GConverterOutputStream*)g_converter_output_stream_new ((GOutputStream*)part_payload_out, compressor);

Expand Down Expand Up @@ -1386,7 +1399,7 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
g_ptr_array_add (part_temp_paths, g_steal_pointer (&part_tmpf));
}

part_in = ot_variant_read (delta_part);
part_in = variant_to_inputstream (delta_part);
if (!ot_gio_splice_get_checksum (part_temp_outstream, part_in,
&part_checksum,
cancellable, error))
Expand Down
13 changes: 0 additions & 13 deletions src/libotutil/ot-variant-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,6 @@ ot_variant_read_fd (int fd,
return TRUE;
}

/* Get an input stream for a GVariant */
GInputStream *
ot_variant_read (GVariant *variant)
{
GMemoryInputStream *ret = (GMemoryInputStream*)
g_memory_input_stream_new_from_data (g_variant_get_data (variant),
g_variant_get_size (variant),
NULL);
g_object_set_data_full ((GObject*)ret, "ot-variant-data",
g_variant_ref (variant), (GDestroyNotify) g_variant_unref);
return (GInputStream*)ret;
}

/* GVariants are immutable; this function allows generating an open builder
* for a new variant, inherting the data from @variant.
*/
Expand Down
2 changes: 0 additions & 2 deletions src/libotutil/ot-variant-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ gboolean ot_variant_read_fd (int fd,
GVariant **out_variant,
GError **error);

GInputStream *ot_variant_read (GVariant *variant);

GVariantBuilder *ot_util_variant_builder_from_variant (GVariant *variant,
const GVariantType *type);

Expand Down

0 comments on commit fc33ae0

Please sign in to comment.