feat: replace output spawn with native tokio method
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-08-03 13:03:57 +02:00
parent 50a929d883
commit 838cd9d6b1
4 changed files with 88 additions and 15 deletions

68
Cargo.lock generated
View File

@@ -17,6 +17,15 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "anstream"
version = "0.6.19"
@@ -601,6 +610,15 @@ version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata 0.1.10",
]
[[package]]
name = "matchit"
version = "0.7.3"
@@ -847,6 +865,50 @@ dependencies = [
"bitflags",
]
[[package]]
name = "regex"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata 0.4.9",
"regex-syntax 0.8.5",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax 0.6.29",
]
[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax 0.8.5",
]
[[package]]
name = "regex-syntax"
version = "0.6.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "ring"
version = "0.17.14"
@@ -1275,10 +1337,14 @@ version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
"regex",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
]
@@ -1326,7 +1392,7 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
[[package]]
name = "voidpin"
version = "0.0.2"
version = "0.0.3"
dependencies = [
"anyhow",
"async-trait",

View File

@@ -13,7 +13,7 @@ version.workspace = true
anyhow.workspace = true
tokio.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter"] }
clap.workspace = true
dotenv.workspace = true

View File

@@ -52,7 +52,7 @@ impl LocalCopier {
pub async fn paste(&self) -> anyhow::Result<Vec<u8>> {
// FIXME: hardcode for macos
#[cfg(target_os = "macos")]
let mut paste_process = {
let paste_process = {
tokio::process::Command::new("pbpaste")
.stdin(Stdio::piped())
.spawn()?
@@ -67,20 +67,19 @@ impl LocalCopier {
let mut paste_process = {
todo!("windows not supported yet");
};
let mut buf = Vec::new();
if let Some(mut stdout_handle) = paste_process.stdout.take() {
stdout_handle
.read_to_end(&mut buf)
.await
.context("failed to write input to paste process")?;
let output = paste_process.wait_with_output().await?;
if !output.status.success() {
anyhow::bail!(
"output failed with: {}, {}, exit_code: {}",
std::str::from_utf8(&output.stdout).unwrap_or_default(),
std::str::from_utf8(&output.stderr).unwrap_or_default(),
output.status.code().unwrap_or_default(),
)
}
let status = paste_process.wait().await?;
tracing::info!("paste process ended with status: {:?}", status);
Ok(buf)
Ok(output.stdout)
}
}

View File

@@ -9,6 +9,7 @@ use remote_copy::RemoteCopierState;
use state::State;
use tokio::io::AsyncWriteExt;
use tonic::transport;
use tracing_subscriber::EnvFilter;
mod grpc {
include!("gen/voidpin.v1.rs");
@@ -64,7 +65,14 @@ enum RemoteCommands {
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenv::dotenv().ok();
tracing_subscriber::fmt::init();
tracing_subscriber::fmt()
.with_env_filter(
EnvFilter::builder()
.with_default_directive("error".parse().unwrap())
.from_env_lossy(),
)
.with_writer(std::io::stderr)
.init();
let cli = Command::parse();
tracing::debug!("Starting cli");