Skip to content

Commit

Permalink
quick fix for: When operating in a console, Windows does not support …
Browse files Browse the repository at this point in the history
…non-UTF-8 byte sequences.
  • Loading branch information
Franz-Aliu Okunega committed Nov 4, 2021
1 parent 3935a56 commit 70bf7fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pg-embed"
version = "0.6.1"
version = "0.6.2"
license = "MIT/Apache-2.0"
readme = "README.md"
repository = "https://github.com/faokunega/pg-embed"
Expand Down
17 changes: 17 additions & 0 deletions src/command_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use tokio::io::{AsyncBufReadExt, AsyncRead, BufReader};
use tokio::process::Child;
use tokio::sync::mpsc::{Receiver, Sender};
use tokio::time::Duration;
use std::str;

///
/// Output logging type
Expand Down Expand Up @@ -165,6 +166,7 @@ where
}
}

#[cfg(target_os = "unix")]
async fn command_execution(&mut self) -> Result<S, E> {
let (sender, receiver) = tokio::sync::mpsc::channel::<LogOutputData>(1000);
let res = self.run_process().await;
Expand All @@ -176,6 +178,21 @@ where
let _ = tokio::task::spawn(async { Self::log_output(receiver).await });
res
}

#[cfg(target_os = "windows")]
async fn command_execution(&mut self) -> Result<S, E> {
let (sender, receiver) = tokio::sync::mpsc::channel::<LogOutputData>(1000);
let res = self.run_process().await;
let stdout = self.process.stdout.take().unwrap();
//TODO: find another way to use stderr on windows
// let stderr = self.process.stderr.take().unwrap();
let tx = sender.clone();
let _ = tokio::task::spawn(async { Self::handle_output(stdout, tx).await });
// let _ = tokio::task::spawn(async { Self::handle_output(stderr, sender).await });
let _ = tokio::task::spawn(async { Self::log_output(receiver).await });
res
}

}

#[async_trait]
Expand Down

0 comments on commit 70bf7fe

Please sign in to comment.