core: Convert public get_object_path() to GFile*
This commit is contained in:
parent
9cf15ed151
commit
860c3cf502
|
|
@ -388,18 +388,9 @@ _ostree_repo_file_tree_get_content_checksum (OstreeRepoFile *self)
|
||||||
GFile *
|
GFile *
|
||||||
_ostree_repo_file_nontree_get_local (OstreeRepoFile *self)
|
_ostree_repo_file_nontree_get_local (OstreeRepoFile *self)
|
||||||
{
|
{
|
||||||
const char *checksum;
|
|
||||||
char *path;
|
|
||||||
GFile *ret;
|
|
||||||
|
|
||||||
g_assert (!ostree_repo_is_archive (self->repo));
|
g_assert (!ostree_repo_is_archive (self->repo));
|
||||||
|
|
||||||
checksum = _ostree_repo_file_get_checksum (self);
|
return ostree_repo_get_object_path (self->repo, _ostree_repo_file_get_checksum (self), OSTREE_OBJECT_TYPE_FILE);
|
||||||
path = ostree_repo_get_object_path (self->repo, checksum, OSTREE_OBJECT_TYPE_FILE);
|
|
||||||
ret = ot_gfile_new_for_path (path);
|
|
||||||
g_free (path);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OstreeRepo *
|
OstreeRepo *
|
||||||
|
|
@ -699,14 +690,7 @@ static GFile *
|
||||||
get_child_local_file (OstreeRepo *repo,
|
get_child_local_file (OstreeRepo *repo,
|
||||||
const char *checksum)
|
const char *checksum)
|
||||||
{
|
{
|
||||||
char *path;
|
return ostree_repo_get_object_path (repo, checksum, OSTREE_OBJECT_TYPE_FILE);
|
||||||
GFile *ret;
|
|
||||||
|
|
||||||
path = ostree_repo_get_object_path (repo, checksum, OSTREE_OBJECT_TYPE_FILE);
|
|
||||||
ret = ot_gfile_new_for_path (path);
|
|
||||||
g_free (path);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
||||||
|
|
@ -733,43 +733,49 @@ import_directory_meta (OstreeRepo *self,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
GFile *
|
||||||
ostree_repo_get_object_path (OstreeRepo *self,
|
ostree_repo_get_object_path (OstreeRepo *self,
|
||||||
const char *checksum,
|
const char *checksum,
|
||||||
OstreeObjectType type)
|
OstreeObjectType type)
|
||||||
{
|
{
|
||||||
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
||||||
char *ret;
|
char *path;
|
||||||
char *relpath;
|
char *relpath;
|
||||||
|
GFile *ret;
|
||||||
|
|
||||||
relpath = ostree_get_relative_object_path (checksum, type, priv->archive);
|
relpath = ostree_get_relative_object_path (checksum, type, priv->archive);
|
||||||
ret = g_build_filename (priv->path, relpath, NULL);
|
path = g_build_filename (priv->path, relpath, NULL);
|
||||||
g_free (relpath);
|
g_free (relpath);
|
||||||
|
ret = ot_gfile_new_for_path (path);
|
||||||
|
g_free (path);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static gboolean
|
||||||
prepare_dir_for_checksum_get_object_path (OstreeRepo *self,
|
prepare_dir_for_checksum_get_object_path (OstreeRepo *self,
|
||||||
const char *checksum,
|
const char *checksum,
|
||||||
OstreeObjectType type,
|
OstreeObjectType type,
|
||||||
|
GFile **out_file,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GFile *f = NULL;
|
gboolean ret = FALSE;
|
||||||
char *checksum_dir = NULL;
|
GFile *checksum_dir = NULL;
|
||||||
char *object_path = NULL;
|
GFile *ret_file = NULL;
|
||||||
|
|
||||||
object_path = ostree_repo_get_object_path (self, checksum, type);
|
ret_file = ostree_repo_get_object_path (self, checksum, type);
|
||||||
checksum_dir = g_path_get_dirname (object_path);
|
checksum_dir = g_file_get_parent (ret_file);
|
||||||
f = ot_gfile_new_for_path (checksum_dir);
|
|
||||||
|
|
||||||
if (!ot_gfile_ensure_directory (f, FALSE, error))
|
if (!ot_gfile_ensure_directory (checksum_dir, FALSE, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
ret = TRUE;
|
||||||
|
*out_file = ret_file;
|
||||||
|
ret_file = NULL;
|
||||||
out:
|
out:
|
||||||
g_clear_object (&f);
|
g_clear_object (&checksum_dir);
|
||||||
g_free (checksum_dir);
|
g_clear_object (&ret_file);
|
||||||
return object_path;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
@ -790,7 +796,8 @@ link_object_trusted (OstreeRepo *self,
|
||||||
DIR *src_dir = NULL;
|
DIR *src_dir = NULL;
|
||||||
DIR *dest_dir = NULL;
|
DIR *dest_dir = NULL;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
char *dest_path = NULL;
|
const char *dest_path = NULL;
|
||||||
|
GFile *dest_file = NULL;
|
||||||
|
|
||||||
src_basename = g_path_get_basename (path);
|
src_basename = g_path_get_basename (path);
|
||||||
src_dirname = g_path_get_dirname (path);
|
src_dirname = g_path_get_dirname (path);
|
||||||
|
|
@ -802,9 +809,9 @@ link_object_trusted (OstreeRepo *self,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
dest_path = prepare_dir_for_checksum_get_object_path (self, checksum, objtype, error);
|
if (!prepare_dir_for_checksum_get_object_path (self, checksum, objtype, &dest_file, error))
|
||||||
if (!dest_path)
|
|
||||||
goto out;
|
goto out;
|
||||||
|
dest_path = ot_gfile_get_path_cached (dest_file);
|
||||||
|
|
||||||
dest_basename = g_path_get_basename (dest_path);
|
dest_basename = g_path_get_basename (dest_path);
|
||||||
dest_dirname = g_path_get_dirname (dest_path);
|
dest_dirname = g_path_get_dirname (dest_path);
|
||||||
|
|
@ -858,7 +865,7 @@ link_object_trusted (OstreeRepo *self,
|
||||||
g_free (dest_basename);
|
g_free (dest_basename);
|
||||||
g_free (tmp_dest_basename);
|
g_free (tmp_dest_basename);
|
||||||
g_free (dest_dirname);
|
g_free (dest_dirname);
|
||||||
g_free (dest_path);
|
g_clear_object (&dest_file);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -876,14 +883,15 @@ archive_file_trusted (OstreeRepo *self,
|
||||||
GFile *outfile = NULL;
|
GFile *outfile = NULL;
|
||||||
GFileOutputStream *out = NULL;
|
GFileOutputStream *out = NULL;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
char *dest_path = NULL;
|
const char *dest_path = NULL;
|
||||||
|
GFile *dest_file = NULL;
|
||||||
char *dest_tmp_path = NULL;
|
char *dest_tmp_path = NULL;
|
||||||
|
|
||||||
infile = ot_gfile_new_for_path (path);
|
infile = ot_gfile_new_for_path (path);
|
||||||
|
|
||||||
dest_path = prepare_dir_for_checksum_get_object_path (self, checksum, objtype, error);
|
if (!prepare_dir_for_checksum_get_object_path (self, checksum, objtype, &dest_file, error))
|
||||||
if (!dest_path)
|
|
||||||
goto out;
|
goto out;
|
||||||
|
dest_path = ot_gfile_get_path_cached (dest_file);
|
||||||
|
|
||||||
dest_tmp_path = g_strconcat (dest_path, ".tmp", NULL);
|
dest_tmp_path = g_strconcat (dest_path, ".tmp", NULL);
|
||||||
|
|
||||||
|
|
@ -906,7 +914,7 @@ archive_file_trusted (OstreeRepo *self,
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
g_free (dest_path);
|
g_clear_object (&dest_file);
|
||||||
g_free (dest_tmp_path);
|
g_free (dest_tmp_path);
|
||||||
g_clear_object (&infile);
|
g_clear_object (&infile);
|
||||||
g_clear_object (&outfile);
|
g_clear_object (&outfile);
|
||||||
|
|
@ -1680,13 +1688,11 @@ ostree_repo_load_variant (OstreeRepo *self,
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
OstreeSerializedVariantType ret_type;
|
OstreeSerializedVariantType ret_type;
|
||||||
GVariant *ret_variant = NULL;
|
GVariant *ret_variant = NULL;
|
||||||
char *path = NULL;
|
|
||||||
GFile *f = NULL;
|
GFile *f = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
path = ostree_repo_get_object_path (self, sha256, OSTREE_OBJECT_TYPE_META);
|
f = ostree_repo_get_object_path (self, sha256, OSTREE_OBJECT_TYPE_META);
|
||||||
f = ot_gfile_new_for_path (path);
|
|
||||||
if (!ostree_parse_metadata_file (f, &ret_type, &ret_variant, error))
|
if (!ostree_parse_metadata_file (f, &ret_type, &ret_variant, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
@ -1698,7 +1704,6 @@ ostree_repo_load_variant (OstreeRepo *self,
|
||||||
if (ret_variant)
|
if (ret_variant)
|
||||||
g_variant_unref (ret_variant);
|
g_variant_unref (ret_variant);
|
||||||
g_clear_object (&f);
|
g_clear_object (&f);
|
||||||
g_free (path);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1764,7 +1769,7 @@ checkout_tree (OstreeRepo *self,
|
||||||
GFileInfo *file_info = NULL;
|
GFileInfo *file_info = NULL;
|
||||||
GFileEnumerator *dir_enum = NULL;
|
GFileEnumerator *dir_enum = NULL;
|
||||||
GFile *child = NULL;
|
GFile *child = NULL;
|
||||||
char *object_path = NULL;
|
GFile *object_path = NULL;
|
||||||
char *dest_path = NULL;
|
char *dest_path = NULL;
|
||||||
|
|
||||||
dir_enum = g_file_enumerate_children ((GFile*)dir, OSTREE_GIO_FAST_QUERYINFO,
|
dir_enum = g_file_enumerate_children ((GFile*)dir, OSTREE_GIO_FAST_QUERYINFO,
|
||||||
|
|
@ -1798,12 +1803,12 @@ checkout_tree (OstreeRepo *self,
|
||||||
|
|
||||||
if (priv->archive)
|
if (priv->archive)
|
||||||
{
|
{
|
||||||
if (!ostree_unpack_object (object_path, OSTREE_OBJECT_TYPE_FILE, dest_path, NULL, error))
|
if (!ostree_unpack_object (ot_gfile_get_path_cached (object_path), OSTREE_OBJECT_TYPE_FILE, dest_path, NULL, error))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (link (object_path, dest_path) < 0)
|
if (link (ot_gfile_get_path_cached (object_path), dest_path) < 0)
|
||||||
{
|
{
|
||||||
ot_util_set_error_from_errno (error, errno);
|
ot_util_set_error_from_errno (error, errno);
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -1811,8 +1816,7 @@ checkout_tree (OstreeRepo *self,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (object_path);
|
g_clear_object (&object_path);
|
||||||
object_path = NULL;
|
|
||||||
g_free (dest_path);
|
g_free (dest_path);
|
||||||
dest_path = NULL;
|
dest_path = NULL;
|
||||||
g_clear_object (&file_info);
|
g_clear_object (&file_info);
|
||||||
|
|
@ -1829,7 +1833,7 @@ checkout_tree (OstreeRepo *self,
|
||||||
g_clear_object (&dir_enum);
|
g_clear_object (&dir_enum);
|
||||||
g_clear_object (&file_info);
|
g_clear_object (&file_info);
|
||||||
g_clear_object (&child);
|
g_clear_object (&child);
|
||||||
g_free (object_path);
|
g_clear_object (&object_path);
|
||||||
g_free (dest_path);
|
g_free (dest_path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ gboolean ostree_repo_write_config (OstreeRepo *self,
|
||||||
GKeyFile *new_config,
|
GKeyFile *new_config,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
char * ostree_repo_get_object_path (OstreeRepo *self,
|
GFile * ostree_repo_get_object_path (OstreeRepo *self,
|
||||||
const char *object,
|
const char *object,
|
||||||
OstreeObjectType type);
|
OstreeObjectType type);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,14 +113,10 @@ do_print_packfile (OstreeRepo *repo,
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
GVariant *variant = NULL;
|
GVariant *variant = NULL;
|
||||||
char *path = NULL;
|
|
||||||
GInputStream *content = NULL;
|
GInputStream *content = NULL;
|
||||||
GFile *file = NULL;
|
GFile *file = NULL;
|
||||||
|
|
||||||
path = ostree_repo_get_object_path (repo, checksum, OSTREE_OBJECT_TYPE_FILE);
|
file = ostree_repo_get_object_path (repo, checksum, OSTREE_OBJECT_TYPE_FILE);
|
||||||
if (!path)
|
|
||||||
goto out;
|
|
||||||
file = ot_gfile_new_for_path (path);
|
|
||||||
|
|
||||||
if (!ostree_parse_packed_file (file, &variant, &content, NULL, error))
|
if (!ostree_parse_packed_file (file, &variant, &content, NULL, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -129,7 +125,6 @@ do_print_packfile (OstreeRepo *repo,
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
g_free (path);
|
|
||||||
g_clear_object (&file);
|
g_clear_object (&file);
|
||||||
g_clear_object (&content);
|
g_clear_object (&content);
|
||||||
if (variant)
|
if (variant)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue