deltas: Use the new internal streaming APIs

This is significantly more efficient.
This commit is contained in:
Colin Walters 2015-02-05 21:35:01 -05:00
parent 7aea18cf0d
commit 96181da26a

View File

@ -484,7 +484,6 @@ dispatch_open_splice_and_close (OstreeRepo *repo,
guint64 objlen;
gs_unref_object GInputStream *object_input = NULL;
gs_unref_object GInputStream *memin = NULL;
gs_unref_object GFileInfo *finfo = NULL;
gs_unref_variant GVariant *xattrs_buf = NULL;
GVariant *modev;
GVariant *xattrs;
@ -510,6 +509,46 @@ dispatch_open_splice_and_close (OstreeRepo *repo,
xattrs = g_variant_get_child_value (state->xattr_dict, xattr_offset);
/* Fast path for regular files to bare repositories */
if (S_ISREG (mode) &&
(repo->mode == OSTREE_REPO_MODE_BARE ||
repo->mode == OSTREE_REPO_MODE_BARE_USER))
{
OstreeRepoTrustedContentBareCommit barecommitstate = { -1 };
gs_unref_object GOutputStream *outstream = NULL;
gsize bytes_written;
gboolean have_obj;
if (!_ostree_repo_open_trusted_content_bare (repo, checksum,
content_size,
&barecommitstate,
&outstream,
&have_obj,
cancellable, error))
goto out;
if (!have_obj)
{
if (!g_output_stream_write_all (outstream, state->payload_data + content_offset,
content_size,
&bytes_written,
cancellable, error))
goto out;
if (!g_output_stream_flush (outstream, cancellable, error))
goto out;
}
if (!_ostree_repo_commit_trusted_content_bare (repo, checksum, &barecommitstate,
uid, gid, mode, xattrs,
cancellable, error))
goto out;
}
else
{
/* Slower path, for symlinks and unpacking deltas into archive-z2 */
gs_unref_object GFileInfo *finfo = NULL;
finfo = _ostree_header_gfile_info_new (mode, uid, gid);
if (S_ISLNK (mode))
@ -525,11 +564,6 @@ dispatch_open_splice_and_close (OstreeRepo *repo,
memin = g_memory_input_stream_new_from_data (state->payload_data + content_offset, content_size, NULL);
}
/* FIXME - Lots of allocation and serialization/deserialization
* going on here. We need an
* ostree_repo_write_content_trusted_raw() that takes raw
* parameters.
*/
if (!ostree_raw_file_to_content_stream (memin, finfo, xattrs,
&object_input, &objlen,
cancellable, error))
@ -543,6 +577,7 @@ dispatch_open_splice_and_close (OstreeRepo *repo,
error))
goto out;
}
}
state->checksum_index++;
state->output_target = NULL;