Fix build
Before I pushed the "move code to a different file" commit, I rebased, but forgot to test the build. Sorry.
This commit is contained in:
parent
91d3b90c9f
commit
3dcff0b2c4
|
|
@ -197,8 +197,8 @@ write_object (OstreeRepo *self,
|
||||||
|
|
||||||
if (expected_checksum)
|
if (expected_checksum)
|
||||||
{
|
{
|
||||||
if (!repo_find_object (self, objtype, expected_checksum, &stored_path,
|
if (!_ostree_repo_find_object (self, objtype, expected_checksum, &stored_path,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -568,188 +568,6 @@ _ostree_repo_get_file_object_path (OstreeRepo *self,
|
||||||
return _ostree_repo_get_object_path (self, checksum, OSTREE_OBJECT_TYPE_FILE);
|
return _ostree_repo_get_object_path (self, checksum, OSTREE_OBJECT_TYPE_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
list_loose_object_dir (OstreeRepo *self,
|
|
||||||
GFile *dir,
|
|
||||||
GHashTable *inout_objects,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
gboolean ret = FALSE;
|
|
||||||
const char *dirname = NULL;
|
|
||||||
const char *dot = NULL;
|
|
||||||
gs_unref_object GFileEnumerator *enumerator = NULL;
|
|
||||||
GString *checksum = NULL;
|
|
||||||
|
|
||||||
dirname = gs_file_get_basename_cached (dir);
|
|
||||||
|
|
||||||
/* We're only querying name */
|
|
||||||
enumerator = g_file_enumerate_children (dir, "standard::name,standard::type",
|
|
||||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
|
||||||
cancellable,
|
|
||||||
error);
|
|
||||||
if (!enumerator)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
ret = TRUE;
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create a randomly-named symbolic link in @tempdir which points to
|
|
||||||
* @target. The filename will be returned in @out_file.
|
|
||||||
*
|
|
||||||
* The reason this odd function exists is that the repo should only
|
|
||||||
* contain objects in their final state. For bare repositories, we
|
|
||||||
* need to first create the symlink, then chown it, and apply all
|
|
||||||
* extended attributes, before finally rename()ing it into place.
|
|
||||||
*/
|
|
||||||
static gboolean
|
|
||||||
make_temporary_symlink (GFile *tmpdir,
|
|
||||||
const char *target,
|
|
||||||
GFile **out_file,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
gboolean ret = FALSE;
|
|
||||||
gs_free char *tmpname = NULL;
|
|
||||||
DIR *d = NULL;
|
|
||||||
int dfd = -1;
|
|
||||||
guint i;
|
|
||||||
const int max_attempts = 128;
|
|
||||||
|
|
||||||
d = opendir (gs_file_get_path_cached (tmpdir));
|
|
||||||
if (!d)
|
|
||||||
{
|
|
||||||
int errsv = errno;
|
|
||||||
g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (errsv),
|
|
||||||
g_strerror (errsv));
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
dfd = dirfd (d);
|
|
||||||
|
|
||||||
for (i = 0; i < max_attempts; i++)
|
|
||||||
{
|
|
||||||
g_free (tmpname);
|
|
||||||
tmpname = gsystem_fileutil_gen_tmp_name (NULL, NULL);
|
|
||||||
if (symlinkat (target, dfd, tmpname) < 0)
|
|
||||||
{
|
|
||||||
if (errno == EEXIST)
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int errsv = errno;
|
|
||||||
g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (errsv),
|
|
||||||
g_strerror (errsv));
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i == max_attempts)
|
|
||||||
{
|
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"Exhausted attempts to open temporary file");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = TRUE;
|
|
||||||
*out_file = g_file_get_child (tmpdir, tmpname);
|
|
||||||
out:
|
|
||||||
if (d) (void) closedir (d);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
stage_object (OstreeRepo *self,
|
|
||||||
OstreeObjectType objtype,
|
|
||||||
const char *expected_checksum,
|
|
||||||
GInputStream *input,
|
|
||||||
guint64 file_object_length,
|
|
||||||
guchar **out_csum,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
gboolean ret = FALSE;
|
|
||||||
const char *actual_checksum;
|
|
||||||
gboolean do_commit;
|
|
||||||
OstreeRepoMode repo_mode;
|
|
||||||
gs_free char *temp_filename = NULL;
|
|
||||||
gs_unref_object GFile *temp_file = NULL;
|
|
||||||
gs_unref_object GFile *raw_temp_file = NULL;
|
|
||||||
gs_unref_object GFile *stored_path = NULL;
|
|
||||||
gs_free guchar *ret_csum = NULL;
|
|
||||||
gs_unref_object OstreeChecksumInputStream *checksum_input = NULL;
|
|
||||||
gs_unref_object GInputStream *file_input = NULL;
|
|
||||||
gs_unref_object GFileInfo *file_info = NULL;
|
|
||||||
gs_unref_variant GVariant *xattrs = NULL;
|
|
||||||
gboolean have_obj;
|
|
||||||
GChecksum *checksum = NULL;
|
|
||||||
gboolean temp_file_is_regular;
|
|
||||||
gboolean is_symlink = FALSE;
|
|
||||||
|
|
||||||
g_return_val_if_fail (self->in_transaction, FALSE);
|
|
||||||
|
|
||||||
while (TRUE)
|
|
||||||
{
|
|
||||||
GFileInfo *file_info;
|
|
||||||
const char *name;
|
|
||||||
guint32 type;
|
|
||||||
OstreeObjectType objtype;
|
|
||||||
|
|
||||||
if (!gs_file_enumerator_iterate (enumerator, &file_info, NULL,
|
|
||||||
NULL, error))
|
|
||||||
goto out;
|
|
||||||
if (file_info == NULL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
type = g_file_info_get_attribute_uint32 (file_info, "standard::type");
|
|
||||||
|
|
||||||
if (type == G_FILE_TYPE_DIRECTORY)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
name = g_file_info_get_attribute_byte_string (file_info, "standard::name");
|
|
||||||
|
|
||||||
if (g_str_has_suffix (name, ".file"))
|
|
||||||
objtype = OSTREE_OBJECT_TYPE_FILE;
|
|
||||||
else if (g_str_has_suffix (name, ".dirtree"))
|
|
||||||
objtype = OSTREE_OBJECT_TYPE_DIR_TREE;
|
|
||||||
else if (g_str_has_suffix (name, ".dirmeta"))
|
|
||||||
objtype = OSTREE_OBJECT_TYPE_DIR_META;
|
|
||||||
else if (g_str_has_suffix (name, ".commit"))
|
|
||||||
objtype = OSTREE_OBJECT_TYPE_COMMIT;
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
|
|
||||||
dot = strrchr (name, '.');
|
|
||||||
g_assert (dot);
|
|
||||||
|
|
||||||
if ((dot - name) == 62)
|
|
||||||
{
|
|
||||||
GVariant *key, *value;
|
|
||||||
|
|
||||||
if (checksum)
|
|
||||||
g_string_free (checksum, TRUE);
|
|
||||||
checksum = g_string_new (dirname);
|
|
||||||
g_string_append_len (checksum, name, 62);
|
|
||||||
|
|
||||||
key = ostree_object_name_serialize (checksum->str, objtype);
|
|
||||||
value = g_variant_new ("(b@as)",
|
|
||||||
TRUE, g_variant_new_strv (NULL, 0));
|
|
||||||
/* transfer ownership */
|
|
||||||
g_hash_table_replace (inout_objects, key,
|
|
||||||
g_variant_ref_sink (value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = TRUE;
|
|
||||||
out:
|
|
||||||
if (checksum)
|
|
||||||
g_string_free (checksum, TRUE);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
append_object_dirs_from (OstreeRepo *self,
|
append_object_dirs_from (OstreeRepo *self,
|
||||||
GFile *dir,
|
GFile *dir,
|
||||||
|
|
@ -834,6 +652,88 @@ _ostree_repo_get_loose_object_dirs (OstreeRepo *self,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
list_loose_object_dir (OstreeRepo *self,
|
||||||
|
GFile *dir,
|
||||||
|
GHashTable *inout_objects,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
const char *dirname = NULL;
|
||||||
|
const char *dot = NULL;
|
||||||
|
gs_unref_object GFileEnumerator *enumerator = NULL;
|
||||||
|
GString *checksum = NULL;
|
||||||
|
|
||||||
|
dirname = gs_file_get_basename_cached (dir);
|
||||||
|
|
||||||
|
/* We're only querying name */
|
||||||
|
enumerator = g_file_enumerate_children (dir, "standard::name,standard::type",
|
||||||
|
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||||
|
cancellable,
|
||||||
|
error);
|
||||||
|
if (!enumerator)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
GFileInfo *file_info;
|
||||||
|
const char *name;
|
||||||
|
guint32 type;
|
||||||
|
OstreeObjectType objtype;
|
||||||
|
|
||||||
|
if (!gs_file_enumerator_iterate (enumerator, &file_info, NULL,
|
||||||
|
NULL, error))
|
||||||
|
goto out;
|
||||||
|
if (file_info == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
type = g_file_info_get_attribute_uint32 (file_info, "standard::type");
|
||||||
|
|
||||||
|
if (type == G_FILE_TYPE_DIRECTORY)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
name = g_file_info_get_attribute_byte_string (file_info, "standard::name");
|
||||||
|
|
||||||
|
if (g_str_has_suffix (name, ".file"))
|
||||||
|
objtype = OSTREE_OBJECT_TYPE_FILE;
|
||||||
|
else if (g_str_has_suffix (name, ".dirtree"))
|
||||||
|
objtype = OSTREE_OBJECT_TYPE_DIR_TREE;
|
||||||
|
else if (g_str_has_suffix (name, ".dirmeta"))
|
||||||
|
objtype = OSTREE_OBJECT_TYPE_DIR_META;
|
||||||
|
else if (g_str_has_suffix (name, ".commit"))
|
||||||
|
objtype = OSTREE_OBJECT_TYPE_COMMIT;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
|
dot = strrchr (name, '.');
|
||||||
|
g_assert (dot);
|
||||||
|
|
||||||
|
if ((dot - name) == 62)
|
||||||
|
{
|
||||||
|
GVariant *key, *value;
|
||||||
|
|
||||||
|
if (checksum)
|
||||||
|
g_string_free (checksum, TRUE);
|
||||||
|
checksum = g_string_new (dirname);
|
||||||
|
g_string_append_len (checksum, name, 62);
|
||||||
|
|
||||||
|
key = ostree_object_name_serialize (checksum->str, objtype);
|
||||||
|
value = g_variant_new ("(b@as)",
|
||||||
|
TRUE, g_variant_new_strv (NULL, 0));
|
||||||
|
/* transfer ownership */
|
||||||
|
g_hash_table_replace (inout_objects, key,
|
||||||
|
g_variant_ref_sink (value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = TRUE;
|
||||||
|
out:
|
||||||
|
if (checksum)
|
||||||
|
g_string_free (checksum, TRUE);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
list_loose_objects (OstreeRepo *self,
|
list_loose_objects (OstreeRepo *self,
|
||||||
GHashTable *inout_objects,
|
GHashTable *inout_objects,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue