lib/deltas: Move variant read helper into the deltas code

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
This commit is contained in:
Colin Walters 2017-10-05 11:14:17 -04:00 committed by Atomic Bot
parent a903f96673
commit fc33ae018d
3 changed files with 15 additions and 17 deletions

View File

@ -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
@ -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);
@ -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))

View File

@ -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.
*/

View File

@ -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);