Skip to content

Commit

Permalink
static-delta-compilation: Move some things around
Browse files Browse the repository at this point in the history
We will do some changes later that need these earliers, so move them up.

Closes: #1309
Approved by: cgwalters
  • Loading branch information
alexlarsson authored and rh-atomic-bot committed Oct 27, 2017
1 parent 74a5df7 commit cbbd159
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions src/libostree/ostree-repo-static-delta-compilation.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@

#define CONTENT_SIZE_SIMILARITY_THRESHOLD_PERCENT (30)

typedef enum {
DELTAOPT_FLAG_NONE = (1 << 0),
DELTAOPT_FLAG_DISABLE_BSDIFF = (1 << 1),
DELTAOPT_FLAG_VERBOSE = (1 << 2)
} DeltaOpts;

typedef struct {
guint64 uncompressed_size;
GPtrArray *objects;
Expand All @@ -62,11 +68,43 @@ typedef struct {
gboolean swap_endian;
} OstreeStaticDeltaBuilder;

typedef enum {
DELTAOPT_FLAG_NONE = (1 << 0),
DELTAOPT_FLAG_DISABLE_BSDIFF = (1 << 1),
DELTAOPT_FLAG_VERBOSE = (1 << 2)
} DeltaOpts;
/* 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;
}

static GBytes *
objtype_checksum_array_new (GPtrArray *objects)
{
guint i;
GByteArray *ret = g_byte_array_new ();

for (i = 0; i < objects->len; i++)
{
GVariant *serialized_key = objects->pdata[i];
OstreeObjectType objtype;
const char *checksum;
guint8 csum[OSTREE_SHA256_DIGEST_LEN];
guint8 objtype_v;

ostree_object_name_deserialize (serialized_key, &checksum, &objtype);
objtype_v = (guint8) objtype;

ostree_checksum_inplace_to_bytes (checksum, csum);

g_byte_array_append (ret, &objtype_v, 1);
g_byte_array_append (ret, csum, sizeof (csum));
}
return g_byte_array_free_to_bytes (ret);
}

static void
ostree_static_delta_part_builder_unref (OstreeStaticDeltaPartBuilder *part_builder)
Expand Down Expand Up @@ -221,31 +259,6 @@ write_unique_variant_chunk (OstreeStaticDeltaPartBuilder *current_part,
return offset;
}

static GBytes *
objtype_checksum_array_new (GPtrArray *objects)
{
guint i;
GByteArray *ret = g_byte_array_new ();

for (i = 0; i < objects->len; i++)
{
GVariant *serialized_key = objects->pdata[i];
OstreeObjectType objtype;
const char *checksum;
guint8 csum[OSTREE_SHA256_DIGEST_LEN];
guint8 objtype_v;

ostree_object_name_deserialize (serialized_key, &checksum, &objtype);
objtype_v = (guint8) objtype;

ostree_checksum_inplace_to_bytes (checksum, csum);

g_byte_array_append (ret, &objtype_v, 1);
g_byte_array_append (ret, csum, sizeof (csum));
}
return g_byte_array_free_to_bytes (ret);
}

static gboolean
splice_stream_to_payload (OstreeStaticDeltaPartBuilder *current_part,
GInputStream *istream,
Expand Down Expand Up @@ -1141,19 +1154,6 @@ 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

0 comments on commit cbbd159

Please sign in to comment.