lib/repo: open file only if required
This tightens up the logic for opening a file while inspecting its xattrs. The only codepath fetching xattrs from a FD is the one handling 'bare' mode. It also rearranges the else-assert flow, mostly for future-proofing.
This commit is contained in:
parent
0713ad3259
commit
b27792ade3
|
|
@ -4218,8 +4218,9 @@ _ostree_repo_load_file_bare (OstreeRepo *self,
|
|||
cancellable, error);
|
||||
}
|
||||
|
||||
const gboolean need_open =
|
||||
(out_fd || out_xattrs || self->mode == OSTREE_REPO_MODE_BARE_USER);
|
||||
const gboolean need_open = (out_fd ||
|
||||
(out_xattrs && self->mode == OSTREE_REPO_MODE_BARE) ||
|
||||
self->mode == OSTREE_REPO_MODE_BARE_USER);
|
||||
/* If it's a regular file and we're requested to return the fd, do it now. As
|
||||
* a special case in bare-user, we always do an open, since the stat() metadata
|
||||
* lives there.
|
||||
|
|
@ -4284,10 +4285,8 @@ _ostree_repo_load_file_bare (OstreeRepo *self,
|
|||
ret_xattrs = g_variant_ref_sink (g_variant_builder_end (&builder));
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (self->mode == OSTREE_REPO_MODE_BARE)
|
||||
{
|
||||
g_assert (self->mode == OSTREE_REPO_MODE_BARE);
|
||||
|
||||
if (S_ISREG (stbuf.st_mode) && out_xattrs)
|
||||
{
|
||||
if (self->disable_xattrs)
|
||||
|
|
@ -4306,6 +4305,10 @@ _ostree_repo_load_file_bare (OstreeRepo *self,
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if (out_fd)
|
||||
*out_fd = glnx_steal_fd (&fd);
|
||||
|
|
|
|||
Loading…
Reference in New Issue