mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
perf: doesn't wait for the process of killing (#128)
This commit is contained in:
parent
a90adf5bc5
commit
0acf345ee3
2 changed files with 4 additions and 5 deletions
1
core/src/external/jq.rs
vendored
1
core/src/external/jq.rs
vendored
|
|
@ -29,6 +29,7 @@ pub async fn jq(path: &Path, skip: usize, limit: usize) -> Result<String, PeekEr
|
||||||
lines.push('\n');
|
lines.push('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
child.start_kill().ok();
|
||||||
if skip > 0 && i < skip + limit {
|
if skip > 0 && i < skip + limit {
|
||||||
Err(PeekError::Exceed(i.saturating_sub(limit)))
|
Err(PeekError::Exceed(i.saturating_sub(limit)))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
8
core/src/external/unar.rs
vendored
8
core/src/external/unar.rs
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{path::Path, process::Stdio};
|
use std::{path::Path, process::Stdio};
|
||||||
|
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use tokio::{io::{AsyncReadExt, BufReader}, process::Command};
|
use tokio::{io::AsyncReadExt, process::Command};
|
||||||
|
|
||||||
pub async fn unar_head(path: &Path, target: &Path) -> Result<Vec<u8>> {
|
pub async fn unar_head(path: &Path, target: &Path) -> Result<Vec<u8>> {
|
||||||
let mut child = Command::new("unar")
|
let mut child = Command::new("unar")
|
||||||
|
|
@ -13,10 +13,8 @@ pub async fn unar_head(path: &Path, target: &Path) -> Result<Vec<u8>> {
|
||||||
.spawn()?;
|
.spawn()?;
|
||||||
|
|
||||||
let mut buf = vec![0; 1024];
|
let mut buf = vec![0; 1024];
|
||||||
let mut reader = BufReader::new(child.stdout.take().unwrap());
|
child.stdout.take().unwrap().read(&mut buf).await.ok();
|
||||||
|
child.start_kill().ok();
|
||||||
reader.read(&mut buf).await.ok();
|
|
||||||
child.kill().await.ok();
|
|
||||||
|
|
||||||
if buf.is_empty() {
|
if buf.is_empty() {
|
||||||
bail!("failed to get head of unar");
|
bail!("failed to get head of unar");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue