diff --git a/yazi-scheduler/src/file/file.rs b/yazi-scheduler/src/file/file.rs index 0d09e8b2..2e435b61 100644 --- a/yazi-scheduler/src/file/file.rs +++ b/yazi-scheduler/src/file/file.rs @@ -8,7 +8,7 @@ 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::{TaskOp, TaskProg, LOW, VERY_LOW}; +use crate::{TaskOp, TaskProg, _LOW, _NORMAL}; pub struct File { macro_: async_priority_channel::Sender, @@ -53,7 +53,7 @@ impl File { { self.log(task.id, format!("Paste task retry: {:?}", task))?; task.retry += 1; - return Ok(self.macro_.send(FileOp::Paste(task).into(), VERY_LOW).await?); + return Ok(self.macro_.send(FileOp::Paste(task).into(), _LOW).await?); } Err(e) => Err(e)?, } @@ -147,9 +147,9 @@ impl File { self.prog.send(TaskProg::New(id, meta.len()))?; if meta.is_file() { - self.macro_.send(FileOp::Paste(task).into(), VERY_LOW).await?; + self.macro_.send(FileOp::Paste(task).into(), _LOW).await?; } else if meta.is_symlink() { - self.macro_.send(FileOp::Link(task.to_link(meta)).into(), LOW).await?; + self.macro_.send(FileOp::Link(task.to_link(meta)).into(), _NORMAL).await?; } return self.succ(id); } @@ -193,9 +193,9 @@ impl File { self.prog.send(TaskProg::New(task.id, meta.len()))?; if meta.is_file() { - self.macro_.send(FileOp::Paste(task.clone()).into(), VERY_LOW).await?; + self.macro_.send(FileOp::Paste(task.clone()).into(), _LOW).await?; } else if meta.is_symlink() { - self.macro_.send(FileOp::Link(task.to_link(meta)).into(), LOW).await?; + self.macro_.send(FileOp::Link(task.to_link(meta)).into(), _NORMAL).await?; } } } @@ -209,7 +209,7 @@ impl File { } self.prog.send(TaskProg::New(id, task.meta.as_ref().unwrap().len()))?; - self.macro_.send(FileOp::Link(task).into(), LOW).await?; + self.macro_.send(FileOp::Link(task).into(), _NORMAL).await?; self.succ(id) } @@ -219,7 +219,7 @@ impl File { let id = task.id; task.length = meta.len(); self.prog.send(TaskProg::New(id, meta.len()))?; - self.macro_.send(FileOp::Delete(task).into(), LOW).await?; + self.macro_.send(FileOp::Delete(task).into(), _NORMAL).await?; return self.succ(id); } @@ -244,7 +244,7 @@ impl File { task.target = Url::from(entry.path()); task.length = meta.len(); self.prog.send(TaskProg::New(task.id, meta.len()))?; - self.macro_.send(FileOp::Delete(task.clone()).into(), LOW).await?; + self.macro_.send(FileOp::Delete(task.clone()).into(), _NORMAL).await?; } } self.succ(task.id) @@ -255,7 +255,7 @@ impl File { task.length = calculate_size(&task.target).await; self.prog.send(TaskProg::New(id, task.length))?; - self.macro_.send(FileOp::Trash(task).into(), VERY_LOW).await?; + self.macro_.send(FileOp::Trash(task).into(), _LOW).await?; self.succ(id) } diff --git a/yazi-scheduler/src/lib.rs b/yazi-scheduler/src/lib.rs index 297404c1..5e93eebd 100644 --- a/yazi-scheduler/src/lib.rs +++ b/yazi-scheduler/src/lib.rs @@ -16,10 +16,8 @@ pub use running::*; pub use scheduler::*; pub use task::*; -const VERY_LOW: u8 = 0; -const LOW: u8 = 1; -const NORMAL: u8 = 2; -const HIGH: u8 = 3; -const VERY_HIGH: u8 = 4; +const _LOW: u8 = 0; +const _NORMAL: u8 = 1; +const _HIGH: u8 = 2; pub fn init() { init_blocker(); } diff --git a/yazi-scheduler/src/plugin/plugin.rs b/yazi-scheduler/src/plugin/plugin.rs index 391b90ee..f9925f0b 100644 --- a/yazi-scheduler/src/plugin/plugin.rs +++ b/yazi-scheduler/src/plugin/plugin.rs @@ -2,7 +2,7 @@ use anyhow::Result; use tokio::sync::mpsc; use super::{PluginOp, PluginOpEntry}; -use crate::{TaskOp, TaskProg, NORMAL}; +use crate::{TaskOp, TaskProg, _HIGH}; pub struct Plugin { macro_: async_priority_channel::Sender, @@ -42,7 +42,7 @@ impl Plugin { let id = task.id; self.prog.send(TaskProg::New(id, 0))?; - self.macro_.try_send(PluginOp::Entry(task).into(), NORMAL)?; + self.macro_.try_send(PluginOp::Entry(task).into(), _HIGH)?; self.succ(id) } } diff --git a/yazi-scheduler/src/scheduler.rs b/yazi-scheduler/src/scheduler.rs index aafaf7db..ed543f94 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::{file::{File, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}, plugin::{Plugin, PluginOpEntry}, preload::{Preload, PreloadOpRule, PreloadOpSize}, process::{Process, ProcessOpOpen}, TaskKind, TaskOp, HIGH, NORMAL, VERY_HIGH, VERY_LOW}; +use crate::{file::{File, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}, plugin::{Plugin, PluginOpEntry}, preload::{Preload, PreloadOpRule, PreloadOpSize}, process::{Process, ProcessOpOpen}, TaskKind, TaskOp, _HIGH, _LOW, _NORMAL}; pub struct Scheduler { pub file: Arc, @@ -117,13 +117,13 @@ impl Scheduler { } if succ > 0 { if let Some(fut) = running.try_remove(id, TaskStage::Pending) { - micro.try_send(fut, HIGH).ok(); + micro.try_send(fut, _NORMAL).ok(); } } } TaskProg::Succ(id) => { if let Some(fut) = running.write().try_remove(id, TaskStage::Dispatched) { - micro.try_send(fut, HIGH).ok(); + micro.try_send(fut, _NORMAL).ok(); } } TaskProg::Fail(id, reason) => { @@ -157,7 +157,7 @@ impl Scheduler { let b = running.all.remove(&id).is_some(); if let Some(hook) = running.hooks.remove(&id) { - self.micro.try_send(hook(true), HIGH).ok(); + self.micro.try_send(hook(true), _HIGH).ok(); } b } @@ -203,7 +203,7 @@ impl Scheduler { file.paste(FileOpPaste { id, from, to, cut: true, follow: false, retry: 0 }).await.ok(); } .boxed(), - VERY_LOW, + _LOW, ); } @@ -220,7 +220,7 @@ impl Scheduler { file.paste(FileOpPaste { id, from, to, cut: false, follow: true, retry: 0 }).await.ok(); } .boxed(), - VERY_LOW, + _LOW, ); } @@ -240,7 +240,7 @@ impl Scheduler { .ok(); } .boxed(), - VERY_LOW, + _LOW, ); } @@ -269,7 +269,7 @@ impl Scheduler { file.delete(FileOpDelete { id, target, length: 0 }).await.ok(); } .boxed(), - VERY_LOW, + _LOW, ); } @@ -283,7 +283,7 @@ impl Scheduler { file.trash(FileOpTrash { id, target, length: 0 }).await.ok(); } .boxed(), - VERY_LOW, + _LOW, ); } @@ -296,7 +296,7 @@ impl Scheduler { plugin.micro(PluginOpEntry { id, name }).await.ok(); } .boxed(), - VERY_HIGH, + _HIGH, ); } @@ -322,7 +322,7 @@ impl Scheduler { preload.rule(PreloadOpRule { id, rule_id, rule_multi, plugin: cmd, targets }).await.ok(); } .boxed(), - HIGH, + _HIGH, ); } @@ -340,7 +340,7 @@ impl Scheduler { preload.size(PreloadOpSize { id, target, throttle }).await.ok(); } .boxed(), - HIGH, + _HIGH, ); } }