diff --git a/yazi-scheduler/src/file/file.rs b/yazi-scheduler/src/file/file.rs index 2e435b61..dc869440 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, _NORMAL}; +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(), _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(), _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(), _NORMAL).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(), _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(), _NORMAL).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(), _NORMAL).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(), _NORMAL).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(), _NORMAL).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(), _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 5e93eebd..a7f92806 100644 --- a/yazi-scheduler/src/lib.rs +++ b/yazi-scheduler/src/lib.rs @@ -16,8 +16,8 @@ pub use running::*; pub use scheduler::*; pub use task::*; -const _LOW: u8 = 0; -const _NORMAL: u8 = 1; -const _HIGH: u8 = 2; +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 f9925f0b..9cff8a32 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, _HIGH}; +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(), _HIGH)?; + 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 ed543f94..1637bbfb 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, _LOW, _NORMAL}; +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, _NORMAL).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, _NORMAL).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(), - _LOW, + LOW, ); } @@ -220,7 +220,7 @@ impl Scheduler { file.paste(FileOpPaste { id, from, to, cut: false, follow: true, retry: 0 }).await.ok(); } .boxed(), - _LOW, + LOW, ); } @@ -240,7 +240,7 @@ impl Scheduler { .ok(); } .boxed(), - _LOW, + LOW, ); } @@ -269,7 +269,7 @@ impl Scheduler { file.delete(FileOpDelete { id, target, length: 0 }).await.ok(); } .boxed(), - _LOW, + LOW, ); } @@ -283,7 +283,7 @@ impl Scheduler { file.trash(FileOpTrash { id, target, length: 0 }).await.ok(); } .boxed(), - _LOW, + LOW, ); } @@ -296,7 +296,7 @@ impl Scheduler { plugin.micro(PluginOpEntry { id, name }).await.ok(); } .boxed(), - _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, ); } }