core: Use linkat() for hardlink checkouts too
Clean up how we deal with the uncompressed object cache; we now use openat()/linkat() and such just like we do for the main objects/. Use linkat() between the objects and the destination, if possible. https://bugzilla.gnome.org/show_bug.cgi?id=707733
This commit is contained in:
1 parent
db148cc9ba
commit
9846fb27fd
6 files changed
+227
-162
No files matched your search
@@ -32,6 +32,29 @@
|
||||
#include "ostree-checksum-input-stream.h"
|
||||
#include "ostree-mutable-tree.h"
|
||||
|
||||
gboolean
|
||||
_ostree_repo_ensure_loose_objdir_at (int dfd,
|
||||
const char *loose_path,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
char loose_prefix[3];
|
||||
|
||||
loose_prefix[0] = loose_path[0];
|
||||
loose_prefix[1] = loose_path[1];
|
||||
loose_prefix[2] = '\0';
|
||||
if (mkdirat (dfd, loose_prefix, 0777) == -1)
|
||||
{
|
||||
int errsv = errno;
|
||||
if (G_UNLIKELY (errsv != EEXIST))
|
||||
{
|
||||
ot_util_set_error_from_errno (error, errsv);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
commit_loose_object_trusted (OstreeRepo *self,
|
||||
const char *loose_path,
|
||||
@@ -40,20 +63,10 @@ commit_loose_object_trusted (OstreeRepo *self,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
char loose_prefix[3];
|
||||
|
||||
loose_prefix[0] = loose_path[0];
|
||||
loose_prefix[1] = loose_path[1];
|
||||
loose_prefix[2] = '\0';
|
||||
if (G_UNLIKELY (mkdirat (self->objects_dir_fd, loose_prefix, 0777) == -1))
|
||||
{
|
||||
int errsv = errno;
|
||||
if (errsv != EEXIST)
|
||||
{
|
||||
ot_util_set_error_from_errno (error, errsv);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
if (!_ostree_repo_ensure_loose_objdir_at (self->objects_dir_fd, loose_path,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (G_UNLIKELY (renameat (self->tmp_dir_fd, tempfile_name,
|
||||
self->objects_dir_fd, loose_path) == -1))
|
||||
@@ -1000,20 +1013,6 @@ _ostree_repo_get_object_path (OstreeRepo *self,
|
||||
return ret;
|
||||
}
|
||||
|
||||
GFile *
|
||||
_ostree_repo_get_uncompressed_object_cache_path (OstreeRepo *self,
|
||||
const char *checksum)
|
||||
{
|
||||
char *relpath;
|
||||
GFile *ret;
|
||||
|
||||
relpath = ostree_get_relative_object_path (checksum, OSTREE_OBJECT_TYPE_FILE, FALSE);
|
||||
ret = g_file_resolve_relative_path (self->uncompressed_objects_dir, relpath);
|
||||
g_free (relpath);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_repo_write_content_trusted:
|
||||
* @self: Repo
|
||||
|
||||
Reference in new issue
Block a user