From 3ec0d45be79714cd3c8cdfb7f798fa2102ed8e02 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Tue, 12 Mar 2024 18:31:12 +0800 Subject: [PATCH] .. --- Cargo.lock | 2 +- yazi-core/src/manager/commands/bulk_rename.rs | 16 ++++++++-------- yazi-plugin/Cargo.toml | 1 - yazi-plugin/src/external/mod.rs | 2 -- yazi-scheduler/Cargo.toml | 3 +++ yazi-scheduler/src/process/mod.rs | 2 ++ yazi-scheduler/src/process/op.rs | 3 ++- yazi-scheduler/src/process/process.rs | 15 +++++---------- .../src/process}/shell.rs | 0 9 files changed, 21 insertions(+), 23 deletions(-) rename {yazi-plugin/src/external => yazi-scheduler/src/process}/shell.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 5c03f312..1f8328ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2810,7 +2810,6 @@ dependencies = [ "anyhow", "crossterm", "futures", - "libc", "md-5", "mlua", "parking_lot", @@ -2859,6 +2858,7 @@ dependencies = [ "base64 0.22.0", "crossterm", "futures", + "libc", "parking_lot", "regex", "tokio", diff --git a/yazi-core/src/manager/commands/bulk_rename.rs b/yazi-core/src/manager/commands/bulk_rename.rs index ca4bf92b..fcea9fb7 100644 --- a/yazi-core/src/manager/commands/bulk_rename.rs +++ b/yazi-core/src/manager/commands/bulk_rename.rs @@ -3,7 +3,6 @@ use std::{collections::HashMap, ffi::{OsStr, OsString}, io::{stdout, BufWriter, use anyhow::{anyhow, Result}; use tokio::{fs::{self, OpenOptions}, io::{stdin, AsyncReadExt, AsyncWriteExt}}; use yazi_config::{OPEN, PREVIEW}; -use yazi_plugin::external::{self, ShellOpt}; use yazi_proxy::{AppProxy, HIDER, WATCHER}; use yazi_shared::{fs::{accessible, max_common_root, File, FilesOp, Url}, term::Term, Defer}; @@ -37,13 +36,14 @@ impl Manager { let _defer2 = Defer::new(|| tokio::spawn(fs::remove_file(tmp.clone()))); AppProxy::stop().await; - let mut child = external::shell(ShellOpt { - cmd: (*opener.run).into(), - args: vec![OsString::new(), tmp.to_owned().into()], - piped: false, - orphan: false, - })?; - child.wait().await?; + // FIXME + // let mut child = super::shell(ShellOpt { + // cmd: (*opener.run).into(), + // args: vec![OsString::new(), tmp.to_owned().into()], + // piped: false, + // orphan: false, + // })?; + // child.wait().await?; let new: Vec<_> = fs::read_to_string(&tmp).await?.lines().map(PathBuf::from).collect(); Self::bulk_rename_do(cwd, root, old, new).await diff --git a/yazi-plugin/Cargo.toml b/yazi-plugin/Cargo.toml index 1727184b..6aa277ad 100644 --- a/yazi-plugin/Cargo.toml +++ b/yazi-plugin/Cargo.toml @@ -36,5 +36,4 @@ unicode-width = "^0" yazi-prebuild = "0.1.2" [target."cfg(unix)".dependencies] -libc = "^0" uzers = "^0" diff --git a/yazi-plugin/src/external/mod.rs b/yazi-plugin/src/external/mod.rs index 92cb58b1..9400cf83 100644 --- a/yazi-plugin/src/external/mod.rs +++ b/yazi-plugin/src/external/mod.rs @@ -3,7 +3,6 @@ mod fzf; mod highlighter; mod lsar; mod rg; -mod shell; mod zoxide; pub use fd::*; @@ -11,5 +10,4 @@ pub use fzf::*; pub use highlighter::*; pub use lsar::*; pub use rg::*; -pub use shell::*; pub use zoxide::*; diff --git a/yazi-scheduler/Cargo.toml b/yazi-scheduler/Cargo.toml index 7c760a29..51b252f3 100644 --- a/yazi-scheduler/Cargo.toml +++ b/yazi-scheduler/Cargo.toml @@ -29,5 +29,8 @@ tokio-stream = "^0" # Logging tracing = { version = "^0", features = [ "max_level_debug", "release_max_level_warn" ] } +[target."cfg(unix)".dependencies] +libc = "^0" + [target.'cfg(not(target_os = "android"))'.dependencies] trash = "^3" diff --git a/yazi-scheduler/src/process/mod.rs b/yazi-scheduler/src/process/mod.rs index 1d72a7b1..e78ef646 100644 --- a/yazi-scheduler/src/process/mod.rs +++ b/yazi-scheduler/src/process/mod.rs @@ -2,6 +2,8 @@ mod op; mod process; +mod shell; pub use op::*; pub use process::*; +pub use shell::*; diff --git a/yazi-scheduler/src/process/op.rs b/yazi-scheduler/src/process/op.rs index 5275b3fa..374f9571 100644 --- a/yazi-scheduler/src/process/op.rs +++ b/yazi-scheduler/src/process/op.rs @@ -1,7 +1,8 @@ use std::ffi::OsString; use tokio::sync::oneshot; -use yazi_plugin::external::ShellOpt; + +use super::ShellOpt; #[derive(Debug)] pub struct ProcessOpOpen { diff --git a/yazi-scheduler/src/process/process.rs b/yazi-scheduler/src/process/process.rs index e1b0e930..587fe497 100644 --- a/yazi-scheduler/src/process/process.rs +++ b/yazi-scheduler/src/process/process.rs @@ -1,10 +1,9 @@ use anyhow::Result; use tokio::{io::{AsyncBufReadExt, BufReader}, select, sync::mpsc}; -use yazi_plugin::external::{self, ShellOpt}; use yazi_proxy::{AppProxy, HIDER}; use yazi_shared::Defer; -use super::ProcessOpOpen; +use super::{ProcessOpOpen, ShellOpt}; use crate::TaskProg; pub struct Process { @@ -24,12 +23,8 @@ impl Process { } self.prog.send(TaskProg::New(task.id, 0))?; - let mut child = external::shell(ShellOpt { - cmd: task.cmd, - args: task.args, - piped: true, - ..Default::default() - })?; + let mut child = + super::shell(ShellOpt { cmd: task.cmd, args: task.args, piped: true, ..Default::default() })?; let mut stdout = BufReader::new(child.stdout.take().unwrap()).lines(); let mut stderr = BufReader::new(child.stderr.take().unwrap()).lines(); @@ -68,7 +63,7 @@ impl Process { AppProxy::stop().await; let (id, cmd) = (task.id, task.cmd.clone()); - let result = external::shell(task.into()); + let result = super::shell(task.into()); if let Err(e) = result { AppProxy::notify_warn(&cmd.to_string_lossy(), &format!("Failed to spawn process: {e}")); return self.succ(id); @@ -88,7 +83,7 @@ impl Process { async fn open_orphan(&self, task: ProcessOpOpen) -> Result<()> { let id = task.id; - match external::shell(task.into()) { + match super::shell(task.into()) { Ok(_) => self.succ(id)?, Err(e) => { self.prog.send(TaskProg::New(id, 0))?; diff --git a/yazi-plugin/src/external/shell.rs b/yazi-scheduler/src/process/shell.rs similarity index 100% rename from yazi-plugin/src/external/shell.rs rename to yazi-scheduler/src/process/shell.rs