lib: Add a helper to convert struct stat → GFileInfo

It's more natural for a few calling places. Prep for patches to go the other
way, which in turn are prep for adding a commit filter v2 that takes `struct
stat`.

`ot_gfile_type_for_mode()` was only used in this function, so inline it here.

Closes: #974
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2017-06-29 18:17:28 +00:00
1 parent 1a9a473580
commit d57410a7e6
8 files changed
+58 -72

No files matched your search

@@ -515,18 +515,15 @@ dispatch_bspatch (OstreeRepo *repo,
static gboolean
handle_untrusted_content_checksum (OstreeRepo *repo,
StaticDeltaExecutionState *state,
GCancellable *cancellable,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GVariant) header = NULL;
g_autoptr(GFileInfo) finfo = NULL;
gsize bytes_written;
finfo = _ostree_header_gfile_info_new (state->mode, state->uid, state->gid);
header = _ostree_file_header_new (finfo, state->xattrs);
g_autoptr(GFileInfo) finfo = _ostree_mode_uidgid_to_gfileinfo (state->mode, state->uid, state->gid);
g_autoptr(GVariant) header = _ostree_file_header_new (finfo, state->xattrs);
state->content_checksum = g_checksum_new (G_CHECKSUM_SHA256);
gsize bytes_written;
if (!_ostree_write_variant_with_size (NULL, header, 0, &bytes_written, state->content_checksum,
cancellable, error))
return FALSE;
@@ -629,9 +626,8 @@ dispatch_open_splice_and_close (OstreeRepo *repo,
else
{
/* Slower path, for symlinks and unpacking deltas into archive-z2 */
g_autoptr(GFileInfo) finfo = NULL;
finfo = _ostree_header_gfile_info_new (state->mode, state->uid, state->gid);
g_autoptr(GFileInfo) finfo =
_ostree_mode_uidgid_to_gfileinfo (state->mode, state->uid, state->gid);
if (S_ISLNK (state->mode))
{