diff --git a/lib/src/cli.rs b/lib/src/cli.rs index af78d3dd..99d223c8 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -1097,7 +1097,7 @@ async fn run_from_opt(opt: Opt) -> Result<()> { // off by default, and must be explicitly enabled. no_signature_verification = !enforce_container_sigpolicy; let sysroot = &if let Some(sysroot) = sysroot { - ostree::Sysroot::new(Some(&gio::File::for_path(&sysroot))) + ostree::Sysroot::new(Some(&gio::File::for_path(sysroot))) } else { ostree::Sysroot::new_default() }; @@ -1118,7 +1118,7 @@ async fn run_from_opt(opt: Opt) -> Result<()> { let booted_stateroot = sysroot .booted_deployment() .map(|d| Cow::Owned(d.osname().to_string())); - booted_stateroot.unwrap_or_else(|| { + booted_stateroot.unwrap_or({ Cow::Borrowed(crate::container::deploy::STATEROOT_DEFAULT) }) }; diff --git a/lib/src/container/store.rs b/lib/src/container/store.rs index ca6d1899..487960bb 100644 --- a/lib/src/container/store.rs +++ b/lib/src/container/store.rs @@ -376,7 +376,7 @@ pub(crate) fn parse_manifest_layout<'a>( let first_layer = manifest .layers() - .get(0) + .first() .ok_or_else(|| anyhow!("No layers in manifest"))?; let target_diffid = config_labels .and_then(|labels| labels.get(DIFFID_LABEL)) @@ -1132,7 +1132,7 @@ pub fn query_image_commit(repo: &ostree::Repo, commit: &str) -> Result( +pub(crate) fn decompress_bridge( src: impl tokio::io::AsyncBufRead + Send + Unpin + 'static, is_zstd: bool, ) -> Result<( @@ -234,7 +234,7 @@ pub(crate) fn decompress_bridge<'a>( } /// Create a decompressor for this MIME type, given a stream of input. -fn new_async_decompressor<'a>( +fn new_async_decompressor( media_type: &oci_image::MediaType, src: impl AsyncBufRead + Send + Unpin + 'static, ) -> Result<( diff --git a/lib/src/container/update_detachedmeta.rs b/lib/src/container/update_detachedmeta.rs index 8aad8bde..f6c469e7 100644 --- a/lib/src/container/update_detachedmeta.rs +++ b/lib/src/container/update_detachedmeta.rs @@ -100,7 +100,7 @@ pub async fn update_detached_metadata( // Splice it into both the manifest and config manifest.layers_mut()[commit_layer_idx] = out_layer_descriptor; - config.rootfs_mut().diff_ids_mut()[commit_layer_idx] = out_layer_diffid.clone(); + config.rootfs_mut().diff_ids_mut()[commit_layer_idx].clone_from(&out_layer_diffid); let labels = ctrcfg.labels_mut().get_or_insert_with(Default::default); // Nothing to do except in the special case where there's somehow only one diff --git a/lib/src/fixture.rs b/lib/src/fixture.rs index 2fedd446..8693f1b3 100644 --- a/lib/src/fixture.rs +++ b/lib/src/fixture.rs @@ -583,7 +583,9 @@ impl Fixture { .timestamp_opt(ostree::commit_get_timestamp(&commit) as i64, 0) .single() .unwrap(); - let new_ts = ts.add(chrono::Duration::days(1)).timestamp() as u64; + let new_ts = ts + .add(chrono::TimeDelta::try_days(1).expect("one day does not overflow")) + .timestamp() as u64; // Prepare a transaction let tx = self.srcrepo.auto_transaction(cancellable)?; diff --git a/lib/src/mountutil.rs b/lib/src/mountutil.rs index 55815116..364928d9 100644 --- a/lib/src/mountutil.rs +++ b/lib/src/mountutil.rs @@ -21,7 +21,7 @@ fn is_mountpoint_impl_statx(root: &Dir, path: &Path) -> Result> { ) { Ok(r) => { let present = (r.stx_attributes_mask & mountroot_flag) > 0; - Ok(present.then(|| r.stx_attributes & mountroot_flag > 0)) + Ok(present.then_some(r.stx_attributes & mountroot_flag > 0)) } Err(e) if e == rustix::io::Errno::NOSYS => Ok(None), Err(e) => Err(e.into()), diff --git a/lib/src/ostree_manual.rs b/lib/src/ostree_manual.rs index a4b30d13..26a12210 100644 --- a/lib/src/ostree_manual.rs +++ b/lib/src/ostree_manual.rs @@ -3,7 +3,6 @@ use std::io::Read; use std::ptr; -use ostree; use ostree::prelude::{Cast, InputStreamExtManual}; use ostree::{gio, glib}; diff --git a/lib/src/ostree_prepareroot.rs b/lib/src/ostree_prepareroot.rs index 1b3ee26e..1227b944 100644 --- a/lib/src/ostree_prepareroot.rs +++ b/lib/src/ostree_prepareroot.rs @@ -22,7 +22,7 @@ pub(crate) fn load_config(root: &ostree::RepoFile) -> Result( ) -> Result<()> { // For chunking, we default to format version 1 #[allow(clippy::needless_update)] - let opts = ExportOptions::default(); + let opts = ExportOptions; let writer = &mut OstreeTarWriter::new(repo, commit, out, opts)?; writer.write_repo_structure()?; write_chunk(writer, chunk) @@ -633,7 +633,7 @@ pub(crate) fn export_final_chunk( remainder: chunking::Chunk, out: &mut tar::Builder, ) -> Result<()> { - let options = ExportOptions::default(); + let options = ExportOptions; let writer = &mut OstreeTarWriter::new(repo, commit_checksum, out, options)?; // For the final chunk, output the commit object, plus all ostree metadata objects along with // the containing directories. diff --git a/lib/src/tar/import.rs b/lib/src/tar/import.rs index 3967cf8f..a251937d 100644 --- a/lib/src/tar/import.rs +++ b/lib/src/tar/import.rs @@ -393,9 +393,9 @@ impl Importer { /// Given a tar entry that looks like an object (its path is under ostree/repo/objects/), /// determine its type and import it. #[context("Importing object {}", path)] - fn import_object<'b, R: std::io::Read>( + fn import_object( &mut self, - entry: tar::Entry<'b, R>, + entry: tar::Entry<'_, R>, path: &Utf8Path, cancellable: Option<&gio::Cancellable>, ) -> Result<()> { diff --git a/lib/src/tar/write.rs b/lib/src/tar/write.rs index 128facde..7218c54c 100644 --- a/lib/src/tar/write.rs +++ b/lib/src/tar/write.rs @@ -377,9 +377,10 @@ pub async fn write_tar( let mut child_stdout = r.stdout.take().unwrap(); let mut child_stderr = r.stderr.take().unwrap(); // Copy the filtered tar stream to child stdin - let mut import_config = TarImportConfig::default(); - import_config.allow_nonusr = options.allow_nonusr; - import_config.remap_factory_var = !options.retain_var; + let import_config = TarImportConfig { + allow_nonusr: options.allow_nonusr, + remap_factory_var: !options.retain_var, + }; let repo_tmpdir = Dir::reopen_dir(&repo.dfd_borrow())? .open_dir("tmp") .context("Getting repo tmpdir")?; @@ -415,7 +416,7 @@ pub async fn write_tar( if let Ok((_, child_stderr)) = output_copier.await { // Avoid trailing newline let child_stderr = child_stderr.trim(); - Err(e.context(format!("{child_stderr}")))? + Err(e.context(child_stderr.to_string()))? } else { Err(e)? } diff --git a/lib/tests/it/main.rs b/lib/tests/it/main.rs index 81444f2d..d6a01791 100644 --- a/lib/tests/it/main.rs +++ b/lib/tests/it/main.rs @@ -488,7 +488,7 @@ async fn impl_test_container_import_export(chunked: bool) -> Result<()> { let cfg = skopeo_inspect_config(&srcoci_imgref.to_string())?; let creation_time = chrono::NaiveDateTime::parse_from_str(cfg.created().as_deref().unwrap(), "%+").unwrap(); - assert_eq!(creation_time.timestamp(), 872879442); + assert_eq!(creation_time.and_utc().timestamp(), 872879442); let found_cfg = cfg.config().as_ref().unwrap(); // unwrap. Unwrap. UnWrap. UNWRAP!!!!!!! assert_eq!(