Skip to content

Commit

Permalink
Refactor: Make filemeta_to_stat a private API
Browse files Browse the repository at this point in the history
Rather than static.  This way I can use it from `ostree-repo-commit.c`.
  • Loading branch information
wmanley committed Jul 1, 2020
1 parent fd8ecdf commit b57c3b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/libostree/ostree-repo-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ _ostree_repo_file_replace_contents (OstreeRepo *self,
GCancellable *cancellable,
GError **error);

GVariant *
_ostree_filemeta_to_stat (struct stat *stbuf,
GBytes *bytes);

gboolean
_ostree_repo_write_ref (OstreeRepo *self,
const char *remote,
Expand Down
13 changes: 7 additions & 6 deletions src/libostree/ostree-repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -3813,13 +3813,16 @@ load_metadata_internal (OstreeRepo *self,
return TRUE;
}

static GVariant *
filemeta_to_stat (struct stat *stbuf,
GVariant *metadata)
GVariant *
_ostree_filemeta_to_stat (struct stat *stbuf,
GBytes *bytes)
{
guint32 uid, gid, mode;
GVariant *xattrs;

g_autoptr(GVariant) metadata = g_variant_ref_sink (g_variant_new_from_bytes (
OSTREE_FILEMETA_GVARIANT_FORMAT, bytes, FALSE));

g_variant_get (metadata, "(uuu@a(ayay))",
&uid, &gid, &mode, &xattrs);
stbuf->st_uid = GUINT32_FROM_BE (uid);
Expand Down Expand Up @@ -3958,9 +3961,7 @@ _ostree_repo_load_file_bare (OstreeRepo *self,
if (bytes == NULL)
return FALSE;

g_autoptr(GVariant) metadata = g_variant_ref_sink (g_variant_new_from_bytes (OSTREE_FILEMETA_GVARIANT_FORMAT,
bytes, FALSE));
ret_xattrs = filemeta_to_stat (&stbuf, metadata);
ret_xattrs = _ostree_filemeta_to_stat (&stbuf, bytes);
if (S_ISLNK (stbuf.st_mode))
{
if (out_symlink)
Expand Down

0 comments on commit b57c3b0

Please sign in to comment.