core: Modify pack file importer to also optionally checksum
For future work on importing from an archive.
This commit is contained in:
parent
bb0867aeb8
commit
177d845f5b
|
|
@ -566,8 +566,9 @@ ostree_pack_file_for_input (GOutputStream *output,
|
||||||
GFileInfo *finfo,
|
GFileInfo *finfo,
|
||||||
GInputStream *instream,
|
GInputStream *instream,
|
||||||
GVariant *xattrs,
|
GVariant *xattrs,
|
||||||
GCancellable *cancellable,
|
GChecksum **out_checksum,
|
||||||
GError **error)
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
guint32 uid, gid, mode;
|
guint32 uid, gid, mode;
|
||||||
|
|
@ -579,6 +580,7 @@ ostree_pack_file_for_input (GOutputStream *output,
|
||||||
GVariantBuilder pack_builder;
|
GVariantBuilder pack_builder;
|
||||||
GVariant *pack_variant = NULL;
|
GVariant *pack_variant = NULL;
|
||||||
gsize bytes_written;
|
gsize bytes_written;
|
||||||
|
GChecksum *ret_checksum = NULL;
|
||||||
|
|
||||||
uid = g_file_info_get_attribute_uint32 (finfo, G_FILE_ATTRIBUTE_UNIX_UID);
|
uid = g_file_info_get_attribute_uint32 (finfo, G_FILE_ATTRIBUTE_UNIX_UID);
|
||||||
gid = g_file_info_get_attribute_uint32 (finfo, G_FILE_ATTRIBUTE_UNIX_GID);
|
gid = g_file_info_get_attribute_uint32 (finfo, G_FILE_ATTRIBUTE_UNIX_GID);
|
||||||
|
|
@ -631,15 +633,10 @@ ostree_pack_file_for_input (GOutputStream *output,
|
||||||
|
|
||||||
if (S_ISREG (mode))
|
if (S_ISREG (mode))
|
||||||
{
|
{
|
||||||
bytes_written = g_output_stream_splice (output, (GInputStream*)instream, 0, cancellable, error);
|
if (!ot_gio_splice_and_checksum (output, (GInputStream*)instream,
|
||||||
if (bytes_written < 0)
|
out_checksum ? &ret_checksum : NULL,
|
||||||
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
if (bytes_written != object_size)
|
|
||||||
{
|
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"File size changed unexpectedly");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (S_ISLNK (mode))
|
else if (S_ISLNK (mode))
|
||||||
{
|
{
|
||||||
|
|
@ -680,7 +677,6 @@ ostree_pack_file (GOutputStream *output,
|
||||||
GFileInfo *finfo = NULL;
|
GFileInfo *finfo = NULL;
|
||||||
GInputStream *instream = NULL;
|
GInputStream *instream = NULL;
|
||||||
GVariant *xattrs = NULL;
|
GVariant *xattrs = NULL;
|
||||||
gsize bytes_written;
|
|
||||||
|
|
||||||
finfo = g_file_query_info (file, "standard::type,standard::size,standard::is-symlink,standard::symlink-target,unix::*",
|
finfo = g_file_query_info (file, "standard::type,standard::size,standard::is-symlink,standard::symlink-target,unix::*",
|
||||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error);
|
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error);
|
||||||
|
|
@ -698,7 +694,7 @@ ostree_pack_file (GOutputStream *output,
|
||||||
if (!xattrs)
|
if (!xattrs)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!ostree_pack_file_for_input (output, finfo, instream, xattrs, cancellable, error))
|
if (!ostree_pack_file_for_input (output, finfo, instream, xattrs, NULL, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,7 @@ gboolean ostree_pack_file_for_input (GOutputStream *output,
|
||||||
GFileInfo *finfo,
|
GFileInfo *finfo,
|
||||||
GInputStream *input,
|
GInputStream *input,
|
||||||
GVariant *xattrs,
|
GVariant *xattrs,
|
||||||
|
GChecksum **out_checksum,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue