diff --git a/yazi-actor/src/mgr/bulk_rename.rs b/yazi-actor/src/mgr/bulk_rename.rs index 6e106413..2681b9e6 100644 --- a/yazi-actor/src/mgr/bulk_rename.rs +++ b/yazi-actor/src/mgr/bulk_rename.rs @@ -46,7 +46,6 @@ impl Actor for BulkRename { tokio::spawn(async move { let tmp = YAZI.preview.tmpfile("bulk"); - batcher.prime(&tmp); Gate::default() .write(true) .create_new(true) @@ -62,6 +61,8 @@ impl Actor for BulkRename { Local::regular(&tmp).remove_file().await }); } + + batcher.prime(&tmp); TasksProxy::process_exec( cwd.into(), Splatter::new(&[UrlCow::default(), tmp.as_url().into()]).splat(&opener.run), diff --git a/yazi-core/src/mgr/batcher.rs b/yazi-core/src/mgr/batcher.rs index 1e1463ef..9b384c8b 100644 --- a/yazi-core/src/mgr/batcher.rs +++ b/yazi-core/src/mgr/batcher.rs @@ -1,11 +1,12 @@ use std::{path::{Path, PathBuf}, sync::Arc}; +use hashbrown::HashMap; use parking_lot::Mutex; use yazi_shared::url::AsUrl; #[derive(Clone, Default)] pub struct Batcher { - pending: Arc)>>, + pending: Arc>>>, } impl Batcher { @@ -13,26 +14,20 @@ impl Batcher { where T: Into, { - *self.pending.lock() = (target.into(), None); + self.pending.lock().insert(target.into(), None); } pub fn drain(&self, target: &Path) -> Option { - let mut pending = self.pending.lock(); - if pending.0 != target { - return None; - } - - pending.0 = PathBuf::default(); - pending.1.take() + self.pending.lock().remove(target).flatten() } pub fn decide(&self, target: T, decision: bool) where T: AsUrl, { - let mut pending = self.pending.lock(); - if target.as_url() == pending.0.as_url() { - pending.1 = Some(decision); + let Some(path) = target.as_url().as_local() else { return }; + if let Some(value) = self.pending.lock().get_mut(path) { + *value = Some(decision); } } }