libostree: Allow compression level to be set for archive-z2 stream

Add a ostree_raw_file_to_archive_z2_stream_with_options() variant of
ostree_raw_file_to_archive_z2_stream(), to allow a compression-level
option to be passed in and passed through to zlib.

This is useful when building archive-z2 files on the fly for
transmission over a non-bandwidth-limited channel, such as a local
network. In this case, CPU time is more valuable than bandwidth, so we
want a low compression level.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #721
Approved by: cgwalters
This commit is contained in:
Philip Withnall 2017-03-06 17:48:36 +00:00 committed by Atomic Bot
parent 72336f1c48
commit 574c3ea6f9
4 changed files with 53 additions and 4 deletions

View File

@ -117,6 +117,7 @@ ostree_content_stream_parse
ostree_content_file_parse
ostree_content_file_parse_at
ostree_raw_file_to_archive_z2_stream
ostree_raw_file_to_archive_z2_stream_with_options
ostree_raw_file_to_content_stream
ostree_checksum_file_from_input
ostree_checksum_file

View File

@ -381,12 +381,10 @@ global:
* NOTE NOTE NOTE
*/
/* Uncomment this when adding the first new symbol for 2
LIBOSTREE_2017.XX {
LIBOSTREE_2017.3 {
global:
someostree_symbol_deleteme;
ostree_raw_file_to_archive_z2_stream_with_options;
} LIBOSTREE_2017.2;
*/
/* Stub section for the stable release *after* this development one; don't
* edit this other than to update the last number. This is just a copy/paste

View File

@ -506,6 +506,46 @@ ostree_raw_file_to_archive_z2_stream (GInputStream *input,
out_input, cancellable, error);
}
/**
* ostree_raw_file_to_archive_z2_stream_with_options:
* @input: File raw content stream
* @file_info: A file info
* @xattrs: (allow-none): Optional extended attributes
* @options: (nullable): A GVariant `a{sv}` with an extensible set of flags
* @out_input: (out): Serialized object stream
* @cancellable: Cancellable
* @error: Error
*
* Like ostree_raw_file_to_archive_z2_stream(), but supports an extensible set
* of flags. The following flags are currently defined:
*
* - `compression-level` (`i`): Level of compression to use, 09, with 0 being
* the least compression, and <0 giving the default level (currently 6).
*
* Since: 2017.3
*/
gboolean
ostree_raw_file_to_archive_z2_stream_with_options (GInputStream *input,
GFileInfo *file_info,
GVariant *xattrs,
GVariant *options,
GInputStream **out_input,
GCancellable *cancellable,
GError **error)
{
gint compression_level = -1;
if (options)
(void) g_variant_lookup (options, "compression-level", "i", &compression_level);
if (compression_level < 0)
compression_level = OSTREE_ARCHIVE_DEFAULT_COMPRESSION_LEVEL;
return _ostree_raw_file_to_archive_stream (input, file_info, xattrs,
compression_level,
out_input, cancellable, error);
}
/**
* ostree_raw_file_to_content_stream:
* @input: File raw content stream

View File

@ -311,6 +311,16 @@ ostree_raw_file_to_archive_z2_stream (GInputStream *input,
GCancellable *cancellable,
GError **error);
_OSTREE_PUBLIC
gboolean
ostree_raw_file_to_archive_z2_stream_with_options (GInputStream *input,
GFileInfo *file_info,
GVariant *xattrs,
GVariant *options,
GInputStream **out_input,
GCancellable *cancellable,
GError **error);
_OSTREE_PUBLIC
gboolean ostree_raw_file_to_content_stream (GInputStream *input,
GFileInfo *file_info,