G_BEGIN_DECLS
+/* It's what gzip does, 9 is too slow */
+#define OSTREE_ARCHIVE_DEFAULT_COMPRESSION_LEVEL (6)
+
/* This file contains private implementation data format definitions
* read by multiple implementation .c files.
*/
GFile *
_ostree_get_default_sysroot_path (void);
+_OSTREE_PUBLIC
+gboolean
+_ostree_raw_file_to_archive_stream (GInputStream *input,
+ GFileInfo *file_info,
+ GVariant *xattrs,
+ guint compression_level,
+ GInputStream **out_input,
+ GCancellable *cancellable,
+ GError **error);
+
+
+
G_END_DECLS
return TRUE;
}
+gboolean
+_ostree_raw_file_to_archive_stream (GInputStream *input,
+ GFileInfo *file_info,
+ GVariant *xattrs,
+ guint compression_level,
+ GInputStream **out_input,
+ GCancellable *cancellable,
+ GError **error)
+{
+ g_autoptr(GVariant) file_header = NULL;
+ g_autoptr(GInputStream) zlib_input = NULL;
+
+ file_header = _ostree_zlib_file_header_new (file_info, xattrs);
+ if (input != NULL)
+ {
+ g_autoptr(GConverter) zlib_compressor = NULL;
+
+ zlib_compressor = G_CONVERTER (g_zlib_compressor_new (G_ZLIB_COMPRESSOR_FORMAT_RAW, compression_level));
+ zlib_input = g_converter_input_stream_new (input, zlib_compressor);
+ }
+ return header_and_input_to_stream (file_header,
+ zlib_input,
+ out_input,
+ NULL,
+ cancellable,
+ error);
+}
+
/**
* ostree_raw_file_to_archive_z2_stream:
* @input: File raw content stream
GCancellable *cancellable,
GError **error)
{
- g_autoptr(GVariant) file_header = NULL;
- g_autoptr(GInputStream) zlib_input = NULL;
-
- file_header = _ostree_zlib_file_header_new (file_info, xattrs);
- if (input != NULL)
- {
- g_autoptr(GConverter) zlib_compressor = NULL;
-
- zlib_compressor = G_CONVERTER (g_zlib_compressor_new (G_ZLIB_COMPRESSOR_FORMAT_RAW, 9));
- zlib_input = g_converter_input_stream_new (input, zlib_compressor);
- }
- return header_and_input_to_stream (file_header,
- zlib_input,
- out_input,
- NULL,
- cancellable,
- error);
+ return _ostree_raw_file_to_archive_stream (input, file_info, xattrs,
+ OSTREE_ARCHIVE_DEFAULT_COMPRESSION_LEVEL,
+ out_input, cancellable, error);
}
/**
if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
{
- zlib_compressor = (GConverter*)g_zlib_compressor_new (G_ZLIB_COMPRESSOR_FORMAT_RAW, 9);
+ zlib_compressor = (GConverter*)g_zlib_compressor_new (G_ZLIB_COMPRESSOR_FORMAT_RAW, self->zlib_compression_level);
compressed_out_stream = g_converter_output_stream_new (temp_out, zlib_compressor);
/* Don't close the base; we'll do that later */
g_filter_output_stream_set_close_base_stream ((GFilterOutputStream*)compressed_out_stream, FALSE);
GError *writable_error;
gboolean in_transaction;
gboolean disable_fsync;
+ guint zlib_compression_level;
GHashTable *loose_object_devino_hash;
GHashTable *updated_uncompressed_dirs;
GHashTable *object_sizes;
self->tmp_expiry_seconds = g_ascii_strtoull (tmp_expiry_seconds, NULL, 10);
}
+ { g_autofree char *compression_level_str = NULL;
+
+ /* gzip defaults to 6 */
+ (void)ot_keyfile_get_value_with_default (self->config, "archive", "zlib-level", NULL,
+ &compression_level_str, NULL);
+
+ if (compression_level_str)
+ /* Ensure level is in [1,9] */
+ self->zlib_compression_level = MAX (1, MIN (9, g_ascii_strtoull (compression_level_str, NULL, 10)));
+ else
+ self->zlib_compression_level = OSTREE_ARCHIVE_DEFAULT_COMPRESSION_LEVEL;
+ }
+
if (!ot_keyfile_get_value_with_default (self->config, "core", "parent",
NULL, &parent_repo_path, error))
return FALSE;