Skip to content

Commit

Permalink
Use tokio SyncIoBridge
Browse files Browse the repository at this point in the history
We can only land this after a new tokio is released with
tokio-rs/tokio#4146
  • Loading branch information
cgwalters committed Oct 30, 2021
1 parent e6d5378 commit 1ed8e29
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 95 deletions.
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ structopt = "0.3.21"
tar = "0.4.33"
tempfile = "3.2.0"
tokio = { features = ["full"], version = "1" }
tokio-util = { features = ["io"], version = "0.6" }
tokio-util = { features = ["io-util"], version = "0.6.9" }
tracing = "0.1"

[dev-dependencies]
Expand Down
88 changes: 0 additions & 88 deletions lib/src/async_util.rs

This file was deleted.

1 change: 0 additions & 1 deletion lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub use ostree::gio::glib;
/// to a string to output to a terminal or logs.
type Result<T> = anyhow::Result<T>;

mod async_util;
pub mod cli;
pub mod container;
pub mod diff;
Expand Down
3 changes: 1 addition & 2 deletions lib/src/tar/import.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! APIs for extracting OSTree commits from container images

use crate::async_util::ReadBridge;
use crate::Result;
use anyhow::{anyhow, Context};
use camino::Utf8Path;
Expand Down Expand Up @@ -603,7 +602,7 @@ pub async fn import_tar(
options: Option<TarImportOptions>,
) -> Result<String> {
let options = options.unwrap_or_default();
let src = ReadBridge::new(src);
let src = tokio_util::io::SyncIoBridge::new(src);
let repo = repo.clone();
let import = crate::tokio_util::spawn_blocking_cancellable(move |cancellable| {
let mut archive = tar::Archive::new(src);
Expand Down
6 changes: 3 additions & 3 deletions lib/src/tar/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//! In the future, this may also evolve into parsing the tar
//! stream in Rust, not in C.

use crate::async_util::{ReadBridge, WriteBridge};
use crate::cmdext::CommandRedirectionExt;
use crate::Result;
use anyhow::{anyhow, Context};
Expand Down Expand Up @@ -163,9 +162,10 @@ async fn filter_tar_async(
mut dest: impl AsyncWrite + Send + Unpin,
) -> Result<BTreeMap<String, u32>> {
let (tx_buf, mut rx_buf) = tokio::io::duplex(8192);
let src = Box::pin(src);
let tar_transformer = tokio::task::spawn_blocking(move || -> Result<_> {
let src = ReadBridge::new(src);
let dest = WriteBridge::new(tx_buf);
let src = tokio_util::io::SyncIoBridge::new(src);
let dest = tokio_util::io::SyncIoBridge::new(tx_buf);
filter_tar(src, dest)
});
let copier = tokio::io::copy(&mut rx_buf, &mut dest);
Expand Down

0 comments on commit 1ed8e29

Please sign in to comment.