diff --git a/README.md b/README.md index 96ecbf0e..bb3fc801 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Yazi (means "duck") is a terminal file manager written in Rust, based on non-blo - πŸ’ͺ **Powerful Async Task Scheduling and Management**: Provides real-time progress updates, task cancellation, and internal task priority assignment. - πŸ–ΌοΈ **Built-in Support for Multiple Image Protocols**: Also integrated with Überzug++, covering almost all terminals. - 🌟 **Built-in Code Highlighting and Image Decoding**: Combined with the pre-loading mechanism, greatly accelerates image and normal file loading. -- πŸ”Œ **Concurrent Plugin System**: UI plugins (rewriting most of the UI), functional plugins, custom previewer, and custom preloader; Just some pieces of Lua. +- πŸ”Œ **Concurrent Plugin System**: UI plugins (rewriting most of the UI), functional plugins, custom previewer/preloader/prefetcher; Just some pieces of Lua. - πŸ“‘ **Data Distribution Service**: Built on a client-server architecture (no additional server process required), integrated with a Lua-based publish-subscribe model, achieving cross-instance communication and state persistence. - πŸ“¦ **Package Manager**: Install plugins and themes with one command, keeping them always up to date, or pin them to a specific version. - 🧰 Integration with fd, rg, fzf, zoxide diff --git a/yazi-config/src/plugin/plugin.rs b/yazi-config/src/plugin/plugin.rs index 33e8f259..0ff574ff 100644 --- a/yazi-config/src/plugin/plugin.rs +++ b/yazi-config/src/plugin/plugin.rs @@ -57,11 +57,11 @@ impl Default for Plugin { panic!("Prefetchers and preloaders exceed the limit of {MAX_PREWORKERS}"); } - for (i, preloader) in shadow.prefetchers.iter_mut().enumerate() { - preloader.id = i as u8; + for (i, p) in shadow.prefetchers.iter_mut().enumerate() { + p.id = i as u8; } - for (i, preloader) in shadow.preloaders.iter_mut().enumerate() { - preloader.id = shadow.prefetchers.len() as u8 + i as u8; + for (i, p) in shadow.preloaders.iter_mut().enumerate() { + p.id = shadow.prefetchers.len() as u8 + i as u8; } Self { diff --git a/yazi-core/src/manager/commands/open.rs b/yazi-core/src/manager/commands/open.rs index be64485c..d3cfadc7 100644 --- a/yazi-core/src/manager/commands/open.rs +++ b/yazi-core/src/manager/commands/open.rs @@ -64,7 +64,7 @@ impl Manager { done.extend(files.iter().map(|f| (f.url(), String::new()))); if let Err(e) = isolate::prefetch("mime", files).await { - error!("preload in open failed: {e}"); + error!("prefetch `mime` failed in opening: {e}"); } ManagerProxy::open_do(OpenDoOpt { hovered, targets: done, interactive: opt.interactive }); diff --git a/yazi-core/src/manager/watcher.rs b/yazi-core/src/manager/watcher.rs index 5349cf3b..9999443c 100644 --- a/yazi-core/src/manager/watcher.rs +++ b/yazi-core/src/manager/watcher.rs @@ -118,7 +118,7 @@ impl Watcher { continue; } if let Err(e) = isolate::prefetch("mime", reload).await { - error!("preload in watcher failed: {e}"); + error!("prefetch `mime` failed in watcher: {e}"); } } } diff --git a/yazi-core/src/tasks/preload.rs b/yazi-core/src/tasks/preload.rs index 1da81a94..7e9760a7 100644 --- a/yazi-core/src/tasks/preload.rs +++ b/yazi-core/src/tasks/preload.rs @@ -84,6 +84,6 @@ impl Tasks { loading.insert(target.clone()); } - self.scheduler.preload_size(targets); + self.scheduler.prework_size(targets); } } diff --git a/yazi-scheduler/src/op.rs b/yazi-scheduler/src/op.rs index f3e100cf..b04dd135 100644 --- a/yazi-scheduler/src/op.rs +++ b/yazi-scheduler/src/op.rs @@ -4,7 +4,7 @@ use crate::{file::FileOp, plugin::PluginOp, preload::PreworkOp}; pub enum TaskOp { File(Box), Plugin(Box), - Preload(Box), + Prework(Box), } impl TaskOp { @@ -12,7 +12,7 @@ impl TaskOp { match self { TaskOp::File(op) => op.id(), TaskOp::Plugin(op) => op.id(), - TaskOp::Preload(op) => op.id(), + TaskOp::Prework(op) => op.id(), } } } @@ -26,5 +26,5 @@ impl From for TaskOp { } impl From for TaskOp { - fn from(op: PreworkOp) -> Self { Self::Preload(Box::new(op)) } + fn from(op: PreworkOp) -> Self { Self::Prework(Box::new(op)) } } diff --git a/yazi-scheduler/src/preload/op.rs b/yazi-scheduler/src/preload/op.rs index fe41a2b9..147db580 100644 --- a/yazi-scheduler/src/preload/op.rs +++ b/yazi-scheduler/src/preload/op.rs @@ -5,9 +5,9 @@ use yazi_shared::{fs::Url, Throttle}; #[derive(Debug)] pub enum PreworkOp { - Fetch(PreloadOpFetch), - Load(PreloadOpLoad), - Size(PreloadOpSize), + Fetch(PreworkOpFetch), + Load(PreworkOpLoad), + Size(PreworkOpSize), } impl PreworkOp { @@ -21,21 +21,21 @@ impl PreworkOp { } #[derive(Clone, Debug)] -pub struct PreloadOpFetch { +pub struct PreworkOpFetch { pub id: usize, pub plugin: PrefetcherProps, pub targets: Vec, } #[derive(Clone, Debug)] -pub struct PreloadOpLoad { +pub struct PreworkOpLoad { pub id: usize, pub plugin: PreloaderProps, pub target: yazi_shared::fs::File, } #[derive(Debug)] -pub struct PreloadOpSize { +pub struct PreworkOpSize { pub id: usize, pub target: Url, pub throttle: Arc>, diff --git a/yazi-scheduler/src/preload/prework.rs b/yazi-scheduler/src/preload/prework.rs index 7cbecf66..9ee7bc97 100644 --- a/yazi-scheduler/src/preload/prework.rs +++ b/yazi-scheduler/src/preload/prework.rs @@ -8,7 +8,7 @@ use yazi_config::Priority; use yazi_plugin::isolate; use yazi_shared::fs::{calculate_size, FilesOp, Url}; -use super::{PreloadOpFetch, PreloadOpLoad, PreloadOpSize, PreworkOp}; +use super::{PreworkOp, PreworkOpFetch, PreworkOpLoad, PreworkOpSize}; use crate::{TaskOp, TaskProg, HIGH, NORMAL}; pub struct Prework { @@ -86,7 +86,7 @@ impl Prework { Ok(()) } - pub async fn fetch(&self, task: PreloadOpFetch) -> Result<()> { + pub async fn fetch(&self, task: PreworkOpFetch) -> Result<()> { let id = task.id; self.prog.send(TaskProg::New(id, 0))?; @@ -98,7 +98,7 @@ impl Prework { self.succ(id) } - pub async fn load(&self, task: PreloadOpLoad) -> Result<()> { + pub async fn load(&self, task: PreworkOpLoad) -> Result<()> { let id = task.id; self.prog.send(TaskProg::New(id, 0))?; @@ -110,7 +110,7 @@ impl Prework { self.succ(id) } - pub async fn size(&self, task: PreloadOpSize) -> Result<()> { + pub async fn size(&self, task: PreworkOpSize) -> Result<()> { let id = task.id; self.prog.send(TaskProg::New(id, 0))?; diff --git a/yazi-scheduler/src/scheduler.rs b/yazi-scheduler/src/scheduler.rs index 89dc357a..8fa0cefc 100644 --- a/yazi-scheduler/src/scheduler.rs +++ b/yazi-scheduler/src/scheduler.rs @@ -9,7 +9,7 @@ use yazi_dds::Pump; use yazi_shared::{event::Data, fs::{unique_path, Url}, Throttle}; use super::{Ongoing, TaskProg, TaskStage}; -use crate::{file::{File, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}, plugin::{Plugin, PluginOpEntry}, preload::{PreloadOpFetch, PreloadOpLoad, PreloadOpSize, Prework}, process::{Process, ProcessOpBg, ProcessOpBlock, ProcessOpOrphan}, TaskKind, TaskOp, HIGH, LOW, NORMAL}; +use crate::{file::{File, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}, plugin::{Plugin, PluginOpEntry}, preload::{Prework, PreworkOpFetch, PreworkOpLoad, PreworkOpSize}, process::{Process, ProcessOpBg, ProcessOpBlock, ProcessOpOrphan}, TaskKind, TaskOp, HIGH, LOW, NORMAL}; pub struct Scheduler { pub file: Arc, @@ -228,7 +228,7 @@ impl Scheduler { let prework = self.prework.clone(); _ = self.micro.try_send( async move { - prework.fetch(PreloadOpFetch { id, plugin, targets }).await.ok(); + prework.fetch(PreworkOpFetch { id, plugin, targets }).await.ok(); } .boxed(), NORMAL, @@ -244,14 +244,14 @@ impl Scheduler { let prework = self.prework.clone(); _ = self.micro.try_send( async move { - prework.load(PreloadOpLoad { id, plugin, target }).await.ok(); + prework.load(PreworkOpLoad { id, plugin, target }).await.ok(); } .boxed(), NORMAL, ); } - pub fn preload_size(&self, targets: Vec<&Url>) { + pub fn prework_size(&self, targets: Vec<&Url>) { let throttle = Arc::new(Throttle::new(targets.len(), Duration::from_millis(300))); let mut ongoing = self.ongoing.lock(); @@ -260,10 +260,10 @@ impl Scheduler { let target = target.clone(); let throttle = throttle.clone(); - let preload = self.prework.clone(); + let prework = self.prework.clone(); _ = self.micro.try_send( async move { - preload.size(PreloadOpSize { id, target, throttle }).await.ok(); + prework.size(PreworkOpSize { id, target, throttle }).await.ok(); } .boxed(), NORMAL, @@ -344,7 +344,7 @@ impl Scheduler { ) -> JoinHandle<()> { let file = self.file.clone(); let plugin = self.plugin.clone(); - let preload = self.prework.clone(); + let prework = self.prework.clone(); let prog = self.prog.clone(); let ongoing = self.ongoing.clone(); @@ -364,7 +364,7 @@ impl Scheduler { let result = match op { TaskOp::File(op) => file.work(*op).await, TaskOp::Plugin(op) => plugin.work(*op).await, - TaskOp::Preload(op) => preload.work(*op).await, + TaskOp::Prework(op) => prework.work(*op).await, }; if let Err(e) = result {