repo: Add ostree_repo_write_symlink

Continuation of the addition of `ostree_repo_write_regfile_inline()`.
This will be helpful for ostree-rs-ext and importing from tar, it's
quite inefficient and awkward for small files to end up creating
a whole `GInputStream` and `GFileInfo` and etc. for small files.
This commit is contained in:
Colin Walters committed 2021-04-08 21:10:00 +00:00
1 parent 9332955b5f
commit fce69cdf70
6 files changed
+66

No files matched your search

+1
View File
@@ -25,6 +25,7 @@
LIBOSTREE_2021.2 {
global:
ostree_repo_write_regfile_inline;
ostree_repo_write_symlink;
} LIBOSTREE_2021.1;
/* Stub section for the stable release *after* this development one; don't
+41
View File
@@ -2814,6 +2814,47 @@ ostree_repo_write_regfile_inline (OstreeRepo *self,
return ostree_checksum_from_bytes (csum);
}
/**
* ostree_repo_write_symlink:
* @self: repo
* @expected_checksum: (allow-none): The expected checksum
* @uid: User id
* @gid: Group id
* @xattrs: (allow-none): Extended attributes, GVariant of type (ayay)
* @symlink_target: Target of the symbolic link
* @cancellable: Cancellable
* @error: Error
*
* Synchronously create a symlink object.
*
* Unlike `ostree_repo_write_content()`, if @expected_checksum is provided,
* this function will not check for the presence of the object beforehand.
*
* Returns: (transfer full): Checksum (as a hex string) of the committed file
* Since: 2021.2
*/
char *
ostree_repo_write_symlink (OstreeRepo *self,
const char *expected_checksum,
guint32 uid,
guint32 gid,
GVariant *xattrs,
const char *symlink_target,
GCancellable *cancellable,
GError **error)
{
g_assert (symlink_target != NULL);
g_autoptr(GFileInfo) finfo = _ostree_mode_uidgid_to_gfileinfo (S_IFLNK | 0777, uid, gid);
g_file_info_set_attribute_byte_string (finfo, "standard::symlink-target", symlink_target);
g_autofree guint8* csum = NULL;
if (!write_content_object (self, expected_checksum,
NULL, finfo, xattrs, &csum,
cancellable, error))
return NULL;
return ostree_checksum_from_bytes (csum);
}
typedef struct {
OstreeRepo *repo;
char *expected_checksum;
+10
View File
@@ -435,6 +435,16 @@ char * ostree_repo_write_regfile_inline (OstreeRepo *self,
GCancellable *cancellable,
GError **error);
_OSTREE_PUBLIC
char * ostree_repo_write_symlink (OstreeRepo *self,
const char *expected_checksum,
guint32 uid,
guint32 gid,
GVariant *xattrs,
const char *symlink_target,
GCancellable *cancellable,
GError **error);
_OSTREE_PUBLIC
gboolean ostree_repo_write_metadata_trusted (OstreeRepo *self,
OstreeObjectType objtype,