mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-01 10:17:47 +03:00
fix: add --follow
option to paste
command (#436)
This commit is contained in:
parent
5fb0fceacb
commit
6b0495f2c5
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,13 +89,13 @@ impl Tasks {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn file_copy(&self, src: &HashSet<Url>, dest: &Url, force: bool) -> bool {
|
||||
pub fn file_copy(&self, src: &HashSet<Url>, 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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user