diff --git a/rust-bindings/tests/repo/generate_static.rs b/rust-bindings/tests/repo/generate_static.rs new file mode 100644 index 00000000..297ce95d --- /dev/null +++ b/rust-bindings/tests/repo/generate_static.rs @@ -0,0 +1,44 @@ +use crate::util::*; +use gio::NONE_CANCELLABLE; +use ostree::glib::prelude::*; +use ostree::glib::Variant; +use ostree::*; + +use std::collections::HashMap; + +#[test] +fn should_generate_static_delta_at() { + let mut options: HashMap = HashMap::::new(); + + let delta_dir = tempfile::tempdir().expect("static delta dir"); + let delta_path = delta_dir.path().join("static_delta.file"); + let path_var = delta_path + .to_str() + .map(std::ffi::CString::new) + .expect("no valid path") + .unwrap() + .as_bytes_with_nul() + .to_variant(); + + let test_repo = TestRepo::new(); + let from = test_repo.test_commit("commit1"); + let to = test_repo.test_commit("commit2"); + + options.insert(String::from("filename"), path_var); + + let varopts = &options.to_variant(); + + let _result = test_repo + .repo + .static_delta_generate( + ostree::StaticDeltaGenerateOpt::Major, + Some(&from), + &to, + None, + Some(varopts), + NONE_CANCELLABLE, + ) + .expect("static delta generate"); + + assert!(delta_path.try_exists().unwrap()); +} diff --git a/rust-bindings/tests/repo/mod.rs b/rust-bindings/tests/repo/mod.rs index 0a94eb9f..0f8967a0 100644 --- a/rust-bindings/tests/repo/mod.rs +++ b/rust-bindings/tests/repo/mod.rs @@ -5,6 +5,7 @@ use ostree::{ObjectName, ObjectType}; #[cfg(feature = "v2016_8")] mod checkout_at; +mod generate_static; #[test] fn should_commit_content_to_repo_and_list_refs_again() { diff --git a/src/libostree/ostree-repo-static-delta-compilation.c b/src/libostree/ostree-repo-static-delta-compilation.c index 28b42139..dece876e 100644 --- a/src/libostree/ostree-repo-static-delta-compilation.c +++ b/src/libostree/ostree-repo-static-delta-compilation.c @@ -1334,9 +1334,9 @@ get_fallback_headers (OstreeRepo *self, * - inline-parts: b: Put part data in header, to get a single file delta. Default FALSE. * - verbose: b: Print diagnostic messages. Default FALSE. * - endianness: b: Deltas use host byte order by default; this option allows choosing (G_BIG_ENDIAN or G_LITTLE_ENDIAN) - * - filename: ay: Save delta superblock to this filename, and parts in the same directory. Default saves to repository. - * - sign-name: ay: Signature type to use. - * - sign-key-ids: as: Array of keys used to sign delta superblock. + * - filename: ^ay: Save delta superblock to this filename (bytestring), and parts in the same directory. Default saves to repository. + * - sign-name: ^ay: Signature type to use (bytestring). + * - sign-key-ids: ^as: NULL-terminated array of keys used to sign delta superblock. */ gboolean ostree_repo_static_delta_generate (OstreeRepo *self, @@ -1409,9 +1409,13 @@ ostree_repo_static_delta_generate (OstreeRepo *self, if (!g_variant_lookup (params, "filename", "^&ay", &opt_filename)) opt_filename = NULL; + else if (opt_filename[0] == '\0') + return glnx_throw (error, "Invalid 'filename' parameter"); if (!g_variant_lookup (params, "sign-name", "^&ay", &opt_sign_name)) opt_sign_name = NULL; + else if (opt_sign_name[0] == '\0') + return glnx_throw (error, "Invalid 'sign-name' parameter"); if (!g_variant_lookup (params, "sign-key-ids", "^a&s", &opt_key_ids)) opt_key_ids = NULL;