diff --git a/yazi-scheduler/src/workers/file.rs b/yazi-scheduler/src/file/file.rs similarity index 92% rename from yazi-scheduler/src/workers/file.rs rename to yazi-scheduler/src/file/file.rs index 0ceed7e8..ff373512 100644 --- a/yazi-scheduler/src/workers/file.rs +++ b/yazi-scheduler/src/file/file.rs @@ -7,6 +7,7 @@ use tracing::warn; use yazi_config::TASKS; use yazi_shared::fs::{calculate_size, copy_with_progress, path_relative_to, Url}; +use super::{FileOp, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}; use crate::TaskProg; pub struct File { @@ -16,49 +17,6 @@ pub struct File { prog: mpsc::UnboundedSender, } -#[derive(Debug)] -pub enum FileOp { - Paste(FileOpPaste), - Link(FileOpLink), - Delete(FileOpDelete), - Trash(FileOpTrash), -} - -#[derive(Clone, Debug)] -pub struct FileOpPaste { - pub id: usize, - pub from: Url, - pub to: Url, - pub cut: bool, - pub follow: bool, - pub retry: u8, -} - -#[derive(Clone, Debug)] -pub struct FileOpLink { - pub id: usize, - pub from: Url, - pub to: Url, - pub meta: Option, - pub resolve: bool, - pub relative: bool, - pub delete: bool, -} - -#[derive(Clone, Debug)] -pub struct FileOpDelete { - pub id: usize, - pub target: Url, - pub length: u64, -} - -#[derive(Clone, Debug)] -pub struct FileOpTrash { - pub id: usize, - pub target: Url, - pub length: u64, -} - impl File { pub fn new(prog: mpsc::UnboundedSender) -> Self { let (tx, rx) = async_channel::unbounded(); diff --git a/yazi-scheduler/src/file/mod.rs b/yazi-scheduler/src/file/mod.rs new file mode 100644 index 00000000..600b5425 --- /dev/null +++ b/yazi-scheduler/src/file/mod.rs @@ -0,0 +1,5 @@ +mod file; +mod op; + +pub use file::*; +pub use op::*; diff --git a/yazi-scheduler/src/file/op.rs b/yazi-scheduler/src/file/op.rs new file mode 100644 index 00000000..4403a20e --- /dev/null +++ b/yazi-scheduler/src/file/op.rs @@ -0,0 +1,46 @@ +use std::fs::Metadata; + +use yazi_shared::fs::Url; + +#[derive(Debug)] +pub enum FileOp { + Paste(FileOpPaste), + Link(FileOpLink), + Delete(FileOpDelete), + Trash(FileOpTrash), +} + +#[derive(Clone, Debug)] +pub struct FileOpPaste { + pub id: usize, + pub from: Url, + pub to: Url, + pub cut: bool, + pub follow: bool, + pub retry: u8, +} + +#[derive(Clone, Debug)] +pub struct FileOpLink { + pub id: usize, + pub from: Url, + pub to: Url, + pub meta: Option, + pub resolve: bool, + pub relative: bool, + pub delete: bool, +} + +#[derive(Clone, Debug)] +pub struct FileOpDelete { + pub id: usize, + pub target: Url, + pub length: u64, +} + +#[derive(Clone, Debug)] +pub struct FileOpTrash { + pub id: usize, + pub target: Url, + pub length: u64, +} diff --git a/yazi-scheduler/src/lib.rs b/yazi-scheduler/src/lib.rs index 6c163d0b..f1e67485 100644 --- a/yazi-scheduler/src/lib.rs +++ b/yazi-scheduler/src/lib.rs @@ -1,6 +1,7 @@ #![allow(clippy::option_map_unit_fn, clippy::unit_arg)] mod blocker; +mod file; mod running; mod scheduler; mod task; diff --git a/yazi-scheduler/src/scheduler.rs b/yazi-scheduler/src/scheduler.rs index fe59b399..d03e047b 100644 --- a/yazi-scheduler/src/scheduler.rs +++ b/yazi-scheduler/src/scheduler.rs @@ -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::{workers::{File, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash, Plugin, PluginOpEntry, Preload, PreloadOpRule, PreloadOpSize, Process, ProcessOpOpen}, TaskKind, TaskOp}; +use crate::{file::{File, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}, workers::{Plugin, PluginOpEntry, Preload, PreloadOpRule, PreloadOpSize, Process, ProcessOpOpen}, TaskKind, TaskOp}; pub struct Scheduler { pub file: Arc, diff --git a/yazi-scheduler/src/task.rs b/yazi-scheduler/src/task.rs index 3a57ab22..40c4a59f 100644 --- a/yazi-scheduler/src/task.rs +++ b/yazi-scheduler/src/task.rs @@ -60,7 +60,7 @@ impl From<&Task> for TaskSummary { #[derive(Debug)] pub enum TaskOp { - File(Box), + File(Box), Plugin(Box), Preload(Box), Process(Box), diff --git a/yazi-scheduler/src/workers/mod.rs b/yazi-scheduler/src/workers/mod.rs index 01cec209..220642e5 100644 --- a/yazi-scheduler/src/workers/mod.rs +++ b/yazi-scheduler/src/workers/mod.rs @@ -1,9 +1,7 @@ -mod file; mod plugin; mod preload; mod process; -pub use file::*; pub use plugin::*; pub use preload::*; pub use process::*;