mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
.. [no ci]
This commit is contained in:
parent
53e6e1bc0a
commit
5962c678a0
9 changed files with 70 additions and 57 deletions
|
|
@ -3,10 +3,11 @@
|
|||
mod blocker;
|
||||
mod file;
|
||||
mod plugin;
|
||||
mod preload;
|
||||
mod process;
|
||||
mod running;
|
||||
mod scheduler;
|
||||
mod task;
|
||||
pub mod workers;
|
||||
|
||||
pub use blocker::*;
|
||||
pub use running::*;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
mod op;
|
||||
mod preload;
|
||||
mod process;
|
||||
|
||||
pub use op::*;
|
||||
pub use preload::*;
|
||||
pub use process::*;
|
||||
25
yazi-scheduler/src/preload/op.rs
Normal file
25
yazi-scheduler/src/preload/op.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use yazi_shared::{fs::Url, Throttle};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum PreloadOp {
|
||||
Rule(PreloadOpRule),
|
||||
Size(PreloadOpSize),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PreloadOpRule {
|
||||
pub id: usize,
|
||||
pub rule_id: u8,
|
||||
pub rule_multi: bool,
|
||||
pub plugin: String,
|
||||
pub targets: Vec<yazi_shared::fs::File>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PreloadOpSize {
|
||||
pub id: usize,
|
||||
pub target: Url,
|
||||
pub throttle: Arc<Throttle<(Url, u64)>>,
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ use tokio::sync::mpsc;
|
|||
use tracing::error;
|
||||
use yazi_shared::{fs::{calculate_size, FilesOp, Url}, Throttle};
|
||||
|
||||
use super::{PreloadOpRule, PreloadOpSize};
|
||||
use crate::TaskProg;
|
||||
|
||||
pub struct Preload {
|
||||
|
|
@ -15,28 +16,6 @@ pub struct Preload {
|
|||
pub size_loading: RwLock<BTreeSet<Url>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum PreloadOp {
|
||||
Rule(PreloadOpRule),
|
||||
Size(PreloadOpSize),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PreloadOpRule {
|
||||
pub id: usize,
|
||||
pub rule_id: u8,
|
||||
pub rule_multi: bool,
|
||||
pub plugin: String,
|
||||
pub targets: Vec<yazi_shared::fs::File>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PreloadOpSize {
|
||||
pub id: usize,
|
||||
pub target: Url,
|
||||
pub throttle: Arc<Throttle<(Url, u64)>>,
|
||||
}
|
||||
|
||||
impl Preload {
|
||||
pub fn new(prog: mpsc::UnboundedSender<TaskProg>) -> Self {
|
||||
Self { prog, rule_loaded: Default::default(), size_loading: Default::default() }
|
||||
5
yazi-scheduler/src/process/mod.rs
Normal file
5
yazi-scheduler/src/process/mod.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
mod op;
|
||||
mod process;
|
||||
|
||||
pub use op::*;
|
||||
pub use process::*;
|
||||
30
yazi-scheduler/src/process/op.rs
Normal file
30
yazi-scheduler/src/process/op.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use std::{ffi::OsString, mem};
|
||||
|
||||
use tokio::sync::oneshot;
|
||||
use yazi_plugin::external::ShellOpt;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ProcessOp {
|
||||
Open(ProcessOpOpen),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ProcessOpOpen {
|
||||
pub id: usize,
|
||||
pub cmd: OsString,
|
||||
pub args: Vec<OsString>,
|
||||
pub block: bool,
|
||||
pub orphan: bool,
|
||||
pub cancel: oneshot::Sender<()>,
|
||||
}
|
||||
|
||||
impl From<&mut ProcessOpOpen> for ShellOpt {
|
||||
fn from(value: &mut ProcessOpOpen) -> Self {
|
||||
Self {
|
||||
cmd: mem::take(&mut value.cmd),
|
||||
args: mem::take(&mut value.args),
|
||||
piped: false,
|
||||
orphan: value.orphan,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +1,14 @@
|
|||
use std::{ffi::OsString, mem};
|
||||
|
||||
use anyhow::Result;
|
||||
use tokio::{io::{AsyncBufReadExt, BufReader}, select, sync::{mpsc, oneshot}};
|
||||
use tokio::{io::{AsyncBufReadExt, BufReader}, select, sync::mpsc};
|
||||
use yazi_plugin::external::{self, ShellOpt};
|
||||
|
||||
use super::ProcessOpOpen;
|
||||
use crate::{Scheduler, TaskProg, BLOCKER};
|
||||
|
||||
pub struct Process {
|
||||
prog: mpsc::UnboundedSender<TaskProg>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ProcessOp {
|
||||
Open(ProcessOpOpen),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ProcessOpOpen {
|
||||
pub id: usize,
|
||||
pub cmd: OsString,
|
||||
pub args: Vec<OsString>,
|
||||
pub block: bool,
|
||||
pub orphan: bool,
|
||||
pub cancel: oneshot::Sender<()>,
|
||||
}
|
||||
|
||||
impl From<&mut ProcessOpOpen> for ShellOpt {
|
||||
fn from(value: &mut ProcessOpOpen) -> Self {
|
||||
Self {
|
||||
cmd: mem::take(&mut value.cmd),
|
||||
args: mem::take(&mut value.args),
|
||||
piped: false,
|
||||
orphan: value.orphan,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Process {
|
||||
pub fn new(prog: mpsc::UnboundedSender<TaskProg>) -> Self { Self { prog } }
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ use yazi_config::{open::Opener, plugin::PluginRule, TASKS};
|
|||
use yazi_shared::{emit, event::Exec, fs::{unique_path, Url}, Layer, Throttle};
|
||||
|
||||
use super::{Running, TaskProg, TaskStage};
|
||||
use crate::{file::{File, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}, plugin::{Plugin, PluginOpEntry}, workers::{Preload, PreloadOpRule, PreloadOpSize, Process, ProcessOpOpen}, TaskKind, TaskOp};
|
||||
use crate::{file::{File, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}, plugin::{Plugin, PluginOpEntry}, preload::{Preload, PreloadOpRule, PreloadOpSize}, process::{Process, ProcessOpOpen}, TaskKind, TaskOp};
|
||||
|
||||
pub struct Scheduler {
|
||||
pub file: Arc<File>,
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ impl From<&Task> for TaskSummary {
|
|||
pub enum TaskOp {
|
||||
File(Box<crate::file::FileOp>),
|
||||
Plugin(Box<crate::plugin::PluginOp>),
|
||||
Preload(Box<crate::workers::PreloadOp>),
|
||||
Process(Box<crate::workers::ProcessOp>),
|
||||
Preload(Box<crate::preload::PreloadOp>),
|
||||
Process(Box<crate::process::ProcessOp>),
|
||||
}
|
||||
|
||||
impl TaskOp {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue