diff --git a/yazi-core/src/manager/commands/paste.rs b/yazi-core/src/manager/commands/paste.rs index 88c9fe9a..f1f11637 100644 --- a/yazi-core/src/manager/commands/paste.rs +++ b/yazi-core/src/manager/commands/paste.rs @@ -3,11 +3,14 @@ use yazi_shared::event::Exec; use crate::{manager::Manager, tasks::Tasks}; pub struct Opt { - force: bool, + force: bool, + follow: bool, } impl From<&Exec> for Opt { - fn from(e: &Exec) -> Self { Self { force: e.named.contains_key("force") } } + fn from(e: &Exec) -> Self { + Self { force: e.named.contains_key("force"), follow: e.named.contains_key("follow") } + } } impl Manager { @@ -16,6 +19,10 @@ impl Manager { let (cut, ref src) = self.yanked; let opt = opt.into() as Opt; - if cut { tasks.file_cut(src, dest, opt.force) } else { tasks.file_copy(src, dest, opt.force) } + if cut { + tasks.file_cut(src, dest, opt.force) + } else { + tasks.file_copy(src, dest, opt.force, opt.follow) + } } } diff --git a/yazi-core/src/tasks/tasks.rs b/yazi-core/src/tasks/tasks.rs index 40bcfb90..e60afd4a 100644 --- a/yazi-core/src/tasks/tasks.rs +++ b/yazi-core/src/tasks/tasks.rs @@ -89,13 +89,13 @@ impl Tasks { false } - pub fn file_copy(&self, src: &HashSet, dest: &Url, force: bool) -> bool { + pub fn file_copy(&self, src: &HashSet, dest: &Url, force: bool, follow: bool) -> bool { for u in src { let to = dest.join(u.file_name().unwrap()); if force && u == &to { debug!("file_copy: same file, skipping {:?}", to); } else { - self.scheduler.file_copy(u.clone(), to, force); + self.scheduler.file_copy(u.clone(), to, force, follow); } } false diff --git a/yazi-scheduler/src/scheduler.rs b/yazi-scheduler/src/scheduler.rs index ad0111f9..c4000409 100644 --- a/yazi-scheduler/src/scheduler.rs +++ b/yazi-scheduler/src/scheduler.rs @@ -207,7 +207,7 @@ impl Scheduler { ); } - pub fn file_copy(&self, from: Url, mut to: Url, force: bool) { + pub fn file_copy(&self, from: Url, mut to: Url, force: bool, follow: bool) { let name = format!("Copy {:?} to {:?}", from, to); let id = self.running.write().add(TaskKind::User, name); @@ -217,7 +217,7 @@ impl Scheduler { if !force { to = unique_path(to).await; } - file.paste(FileOpPaste { id, from, to, cut: false, follow: true, retry: 0 }).await.ok(); + file.paste(FileOpPaste { id, from, to, cut: false, follow, retry: 0 }).await.ok(); } .boxed(), LOW,