core: Convert metadata parsing API to GFile
This commit is contained in:
parent
218684786d
commit
2c2b9c0e00
|
|
@ -395,19 +395,17 @@ ostree_set_xattrs (GFile *f,
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_parse_metadata_file (const char *path,
|
ostree_parse_metadata_file (GFile *file,
|
||||||
OstreeSerializedVariantType *out_type,
|
OstreeSerializedVariantType *out_type,
|
||||||
GVariant **out_variant,
|
GVariant **out_variant,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GFile *pathf = NULL;
|
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
GVariant *ret_variant = NULL;
|
GVariant *ret_variant = NULL;
|
||||||
GVariant *container = NULL;
|
GVariant *container = NULL;
|
||||||
guint32 ret_type;
|
guint32 ret_type;
|
||||||
|
|
||||||
pathf = ot_util_new_file_for_path (path);
|
if (!ot_util_variant_map (file, G_VARIANT_TYPE (OSTREE_SERIALIZED_VARIANT_FORMAT),
|
||||||
if (!ot_util_variant_map (pathf, G_VARIANT_TYPE (OSTREE_SERIALIZED_VARIANT_FORMAT),
|
|
||||||
&container, error))
|
&container, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
@ -417,7 +415,8 @@ ostree_parse_metadata_file (const char *path,
|
||||||
if (ret_type <= 0 || ret_type > OSTREE_SERIALIZED_VARIANT_LAST)
|
if (ret_type <= 0 || ret_type > OSTREE_SERIALIZED_VARIANT_LAST)
|
||||||
{
|
{
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
"Corrupted metadata object '%s'; invalid type %d", path, ret_type);
|
"Corrupted metadata object '%s'; invalid type %d",
|
||||||
|
ot_gfile_get_path_cached (file), ret_type);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -430,7 +429,6 @@ ostree_parse_metadata_file (const char *path,
|
||||||
g_variant_unref (ret_variant);
|
g_variant_unref (ret_variant);
|
||||||
if (container != NULL)
|
if (container != NULL)
|
||||||
g_variant_unref (container);
|
g_variant_unref (container);
|
||||||
g_clear_object (&pathf);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ GVariant *ostree_get_xattrs_for_file (GFile *f,
|
||||||
gboolean ostree_set_xattrs (GFile *f, GVariant *xattrs,
|
gboolean ostree_set_xattrs (GFile *f, GVariant *xattrs,
|
||||||
GCancellable *cancellable, GError **error);
|
GCancellable *cancellable, GError **error);
|
||||||
|
|
||||||
gboolean ostree_parse_metadata_file (const char *path,
|
gboolean ostree_parse_metadata_file (GFile *file,
|
||||||
OstreeSerializedVariantType *out_type,
|
OstreeSerializedVariantType *out_type,
|
||||||
GVariant **out_variant,
|
GVariant **out_variant,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
|
||||||
|
|
@ -1675,11 +1675,13 @@ ostree_repo_load_variant (OstreeRepo *self,
|
||||||
OstreeSerializedVariantType ret_type;
|
OstreeSerializedVariantType ret_type;
|
||||||
GVariant *ret_variant = NULL;
|
GVariant *ret_variant = NULL;
|
||||||
char *path = NULL;
|
char *path = 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);
|
path = ostree_repo_get_object_path (self, sha256, OSTREE_OBJECT_TYPE_META);
|
||||||
if (!ostree_parse_metadata_file (path, &ret_type, &ret_variant, error))
|
f = ot_util_new_file_for_path (path);
|
||||||
|
if (!ostree_parse_metadata_file (f, &ret_type, &ret_variant, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
@ -1689,6 +1691,7 @@ ostree_repo_load_variant (OstreeRepo *self,
|
||||||
out:
|
out:
|
||||||
if (ret_variant)
|
if (ret_variant)
|
||||||
g_variant_unref (ret_variant);
|
g_variant_unref (ret_variant);
|
||||||
|
g_clear_object (&f);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue