repo: Port APIs used by prune to fd-relative *at calls
More of the general trend away from GFile * to the faster and more secure world of *at().
This commit is contained in:
parent
474b071055
commit
3b3708c312
|
|
@ -2324,19 +2324,39 @@ ostree_repo_delete_object (OstreeRepo *self,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
gs_unref_object GFile *objpath = NULL;
|
int res;
|
||||||
|
char loose_path[_OSTREE_LOOSE_PATH_MAX];
|
||||||
|
|
||||||
|
_ostree_loose_path (loose_path, sha256, objtype, self->mode);
|
||||||
|
|
||||||
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
|
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
|
||||||
{
|
{
|
||||||
gs_unref_object GFile *detached_metadata =
|
char meta_loose[_OSTREE_LOOSE_PATH_MAX];
|
||||||
_ostree_repo_get_commit_metadata_loose_path (self, sha256);
|
|
||||||
if (!ot_gfile_ensure_unlinked (detached_metadata, cancellable, error))
|
_ostree_loose_path_with_suffix (meta_loose, sha256,
|
||||||
|
OSTREE_OBJECT_TYPE_COMMIT, self->mode, "meta");
|
||||||
|
|
||||||
|
do
|
||||||
|
res = unlinkat (self->objects_dir_fd, meta_loose, 0);
|
||||||
|
while (G_UNLIKELY (res == -1 && errno == EINTR));
|
||||||
|
if (res == -1)
|
||||||
|
{
|
||||||
|
if (G_UNLIKELY (errno != ENOENT))
|
||||||
|
{
|
||||||
|
gs_set_error_from_errno (error, errno);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
objpath = _ostree_repo_get_object_path (self, sha256, objtype);
|
do
|
||||||
if (!gs_file_unlink (objpath, cancellable, error))
|
res = unlinkat (self->objects_dir_fd, loose_path, 0);
|
||||||
|
while (G_UNLIKELY (res == -1 && errno == EINTR));
|
||||||
|
if (G_UNLIKELY (res == -1))
|
||||||
|
{
|
||||||
|
gs_set_error_from_errno (error, errno);
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
|
|
@ -2539,14 +2559,22 @@ ostree_repo_query_object_storage_size (OstreeRepo *self,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
gs_unref_object GFile *objpath = _ostree_repo_get_object_path (self, sha256, objtype);
|
char loose_path[_OSTREE_LOOSE_PATH_MAX];
|
||||||
gs_unref_object GFileInfo *finfo = g_file_query_info (objpath, OSTREE_GIO_FAST_QUERYINFO,
|
int res;
|
||||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
struct stat stbuf;
|
||||||
cancellable, error);
|
|
||||||
if (!finfo)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
*out_size = g_file_info_get_size (finfo);
|
_ostree_loose_path (loose_path, sha256, objtype, self->mode);
|
||||||
|
|
||||||
|
do
|
||||||
|
res = fstatat (self->objects_dir_fd, loose_path, &stbuf, AT_SYMLINK_NOFOLLOW);
|
||||||
|
while (G_UNLIKELY (res == -1 && errno == EINTR));
|
||||||
|
if (G_UNLIKELY (res == -1))
|
||||||
|
{
|
||||||
|
gs_set_error_from_errno (error, errno);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out_size = stbuf.st_size;
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue