Fix some issues with RepoFile

This commit is contained in:
Felix Krull 2019-05-18 17:18:11 +02:00 committed by Colin Walters
parent 26b5729c53
commit 0bf8f3f52e
3 changed files with 63 additions and 19 deletions

View File

@ -22,6 +22,7 @@ generate = [
"OSTree.RepoCommitModifier",
"OSTree.RepoCommitState",
"OSTree.RepoDevInoCache",
"OSTree.RepoFile",
"OSTree.RepoListRefsExtFlags",
"OSTree.RepoMode",
"OSTree.RepoPruneFlags",
@ -78,21 +79,6 @@ status = "generate"
pattern = ".+_async"
ignore = true
[[object]]
name = "OSTree.RepoFile"
status = "generate"
[[object.function]]
pattern = "get_xattrs"
ignore = true
[[object.function]]
pattern = "tree_find_child"
ignore = true
[[object.function]]
pattern = "tree_query_child"
ignore = true
[[object]]
name = "OSTree.*"
status = "generate"

View File

@ -8049,15 +8049,23 @@ options. This is used by ostree_repo_export_tree_to_archive().</doc>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">#OstreeRepoFile</doc>
<type name="RepoFile" c:type="OstreeRepoFile*"/>
</instance-parameter>
<parameter name="out_xattrs" transfer-ownership="none">
<parameter name="out_xattrs"
direction="out"
caller-allocates="0"
transfer-ownership="full"
optional="1"
allow-none="1">
<doc xml:space="preserve">the extended attributes</doc>
<type name="GLib.Variant" c:type="GVariant**"/>
</parameter>
<parameter name="cancellable"
transfer-ownership="none"
nullable="1"
allow-none="1">
<doc xml:space="preserve">Cancellable</doc>
<type name="Gio.Cancellable" c:type="GCancellable*"/>
</parameter>
</parameters>
@ -8069,15 +8077,23 @@ options. This is used by ostree_repo_export_tree_to_archive().</doc>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">#OstreeRepoFile</doc>
<type name="RepoFile" c:type="OstreeRepoFile*"/>
</instance-parameter>
<parameter name="name" transfer-ownership="none">
<doc xml:space="preserve">name of the child</doc>
<type name="utf8" c:type="const char*"/>
</parameter>
<parameter name="is_dir" transfer-ownership="none">
<parameter name="is_dir"
direction="out"
caller-allocates="1"
transfer-ownership="none">
<type name="gboolean" c:type="gboolean*"/>
</parameter>
<parameter name="out_container" transfer-ownership="none">
<parameter name="out_container"
direction="out"
caller-allocates="0"
transfer-ownership="full">
<type name="GLib.Variant" c:type="GVariant**"/>
</parameter>
</parameters>
@ -8134,6 +8150,7 @@ options. This is used by ostree_repo_export_tree_to_archive().</doc>
</return-value>
<parameters>
<instance-parameter name="self" transfer-ownership="none">
<doc xml:space="preserve">#OstreeRepoFile</doc>
<type name="RepoFile" c:type="OstreeRepoFile*"/>
</instance-parameter>
<parameter name="n" transfer-ownership="none">
@ -8145,13 +8162,17 @@ options. This is used by ostree_repo_export_tree_to_archive().</doc>
<parameter name="flags" transfer-ownership="none">
<type name="Gio.FileQueryInfoFlags" c:type="GFileQueryInfoFlags"/>
</parameter>
<parameter name="out_info" transfer-ownership="none">
<parameter name="out_info"
direction="out"
caller-allocates="0"
transfer-ownership="full">
<type name="Gio.FileInfo" c:type="GFileInfo**"/>
</parameter>
<parameter name="cancellable"
transfer-ownership="none"
nullable="1"
allow-none="1">
<doc xml:space="preserve">Cancellable</doc>
<type name="Gio.Cancellable" c:type="GCancellable*"/>
</parameter>
</parameters>

View File

@ -34,6 +34,10 @@ pub trait RepoFileExt {
fn get_root(&self) -> Option<RepoFile>;
fn get_xattrs<'a, P: Into<Option<&'a gio::Cancellable>>>(&self, cancellable: P) -> Result<glib::Variant, Error>;
fn tree_find_child(&self, name: &str) -> (i32, bool, glib::Variant);
fn tree_get_contents(&self) -> Option<glib::Variant>;
fn tree_get_contents_checksum(&self) -> Option<String>;
@ -42,6 +46,8 @@ pub trait RepoFileExt {
fn tree_get_metadata_checksum(&self) -> Option<String>;
fn tree_query_child<'a, P: Into<Option<&'a gio::Cancellable>>>(&self, n: i32, attributes: &str, flags: gio::FileQueryInfoFlags, cancellable: P) -> Result<gio::FileInfo, Error>;
fn tree_set_metadata(&self, checksum: &str, metadata: &glib::Variant);
}
@ -72,6 +78,26 @@ impl<O: IsA<RepoFile>> RepoFileExt for O {
}
}
fn get_xattrs<'a, P: Into<Option<&'a gio::Cancellable>>>(&self, cancellable: P) -> Result<glib::Variant, Error> {
let cancellable = cancellable.into();
let cancellable = cancellable.to_glib_none();
unsafe {
let mut out_xattrs = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_repo_file_get_xattrs(self.to_glib_none().0, &mut out_xattrs, cancellable.0, &mut error);
if error.is_null() { Ok(from_glib_full(out_xattrs)) } else { Err(from_glib_full(error)) }
}
}
fn tree_find_child(&self, name: &str) -> (i32, bool, glib::Variant) {
unsafe {
let mut is_dir = mem::uninitialized();
let mut out_container = ptr::null_mut();
let ret = ffi::ostree_repo_file_tree_find_child(self.to_glib_none().0, name.to_glib_none().0, &mut is_dir, &mut out_container);
(ret, from_glib(is_dir), from_glib_full(out_container))
}
}
fn tree_get_contents(&self) -> Option<glib::Variant> {
unsafe {
from_glib_full(ffi::ostree_repo_file_tree_get_contents(self.to_glib_none().0))
@ -96,6 +122,17 @@ impl<O: IsA<RepoFile>> RepoFileExt for O {
}
}
fn tree_query_child<'a, P: Into<Option<&'a gio::Cancellable>>>(&self, n: i32, attributes: &str, flags: gio::FileQueryInfoFlags, cancellable: P) -> Result<gio::FileInfo, Error> {
let cancellable = cancellable.into();
let cancellable = cancellable.to_glib_none();
unsafe {
let mut out_info = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_repo_file_tree_query_child(self.to_glib_none().0, n, attributes.to_glib_none().0, flags.to_glib(), &mut out_info, cancellable.0, &mut error);
if error.is_null() { Ok(from_glib_full(out_info)) } else { Err(from_glib_full(error)) }
}
}
fn tree_set_metadata(&self, checksum: &str, metadata: &glib::Variant) {
unsafe {
ffi::ostree_repo_file_tree_set_metadata(self.to_glib_none().0, checksum.to_glib_none().0, metadata.to_glib_none().0);