-
Notifications
You must be signed in to change notification settings - Fork 457
Open
Labels
Description
In the tauri_plugin_shell::process::Command, we have the output method which automatically collects all output from the sidecar command. The issue with it is that it inserts \n after each received chunk. In case of handling raw output (i.e. binary output; for example, images, PDFs, etc.), this behavior breaks the received buffer.
It would be nice to have a boolean parameter or a separate method for collecting the output without inserting \n between chunks.
plugins-workspace/plugins/shell/src/process/mod.rs
Lines 366 to 394 in 1a03e97
| pub async fn output(self) -> crate::Result<Output> { | |
| let (mut rx, _child) = self.spawn()?; | |
| let mut code = None; | |
| let mut stdout = Vec::new(); | |
| let mut stderr = Vec::new(); | |
| while let Some(event) = rx.recv().await { | |
| match event { | |
| CommandEvent::Terminated(payload) => { | |
| code = payload.code; | |
| } | |
| CommandEvent::Stdout(line) => { | |
| stdout.extend(line); | |
| stdout.push(NEWLINE_BYTE); | |
| } | |
| CommandEvent::Stderr(line) => { | |
| stderr.extend(line); | |
| stderr.push(NEWLINE_BYTE); | |
| } | |
| CommandEvent::Error(_) => {} | |
| } | |
| } | |
| Ok(Output { | |
| status: ExitStatus { code }, | |
| stdout, | |
| stderr, | |
| }) | |
| } |