This commit is contained in:
sxyazi 2025-12-05 23:22:29 +08:00
parent dbb8c6d28f
commit 7f80ed8864
No known key found for this signature in database
3 changed files with 19 additions and 19 deletions

View file

@ -27,20 +27,20 @@ impl File {
pub(crate) async fn paste(&self, mut task: FileInPaste) -> Result<(), FileOutPaste> { pub(crate) async fn paste(&self, mut task: FileInPaste) -> Result<(), FileOutPaste> {
if task.cut if task.cut
&& !task.follow1 && !task.follow
&& ok_or_not_found(provider::rename(&task.from, &task.to).await).is_ok() && ok_or_not_found(provider::rename(&task.from, &task.to).await).is_ok()
{ {
return Ok(self.ops.out(task.id, FileOutPaste::Succ)); return Ok(self.ops.out(task.id, FileOutPaste::Succ));
} }
if task.cha.is_none() { if task.cha.is_none() {
task.cha = Some(Self::cha(&task.from, task.follow1, None).await?); task.cha = Some(Self::cha(&task.from, task.follow, None).await?);
} }
let cha = task.cha.unwrap(); let cha = task.cha.unwrap();
if !cha.is_dir() { if !cha.is_dir() {
let id = task.id; let id = task.id;
if cha.is_orphan() || (cha.is_link() && !task.follow1) { if cha.is_orphan() || (cha.is_link() && !task.follow) {
self.ops.out(id, FileOutPaste::New(0)); self.ops.out(id, FileOutPaste::New(0));
self.queue(task.into_link(), NORMAL); self.queue(task.into_link(), NORMAL);
} else { } else {
@ -76,7 +76,7 @@ impl File {
let mut it = continue_unless_ok!(provider::read_dir(&src).await); let mut it = continue_unless_ok!(provider::read_dir(&src).await);
while let Ok(Some(entry)) = it.next().await { while let Ok(Some(entry)) = it.next().await {
let from = entry.url(); let from = entry.url();
let cha = continue_unless_ok!(Self::cha(&from, task.follow1, Some(entry)).await); let cha = continue_unless_ok!(Self::cha(&from, task.follow, Some(entry)).await);
if cha.is_dir() { if cha.is_dir() {
dirs.push_back(from); dirs.push_back(from);
@ -84,7 +84,7 @@ impl File {
} }
let to = continue_unless_ok!(dest.try_join(from.name().unwrap())); let to = continue_unless_ok!(dest.try_join(from.name().unwrap()));
if cha.is_orphan() || (cha.is_link() && !task.follow1) { if cha.is_orphan() || (cha.is_link() && !task.follow) {
self.ops.out(task.id, FileOutPaste::New(0)); self.ops.out(task.id, FileOutPaste::New(0));
self.queue(task.spawn(from, to, cha).into_link(), NORMAL); self.queue(task.spawn(from, to, cha).into_link(), NORMAL);
} else { } else {
@ -111,12 +111,12 @@ impl File {
} }
Ok(n) => self.ops.out(task.id, FileOutPasteDo::Adv(n)), Ok(n) => self.ops.out(task.id, FileOutPasteDo::Adv(n)),
Err(e) if e.kind() == NotFound => { Err(e) if e.kind() == NotFound => {
let Ok(cha) = Self::cha(&task.from, task.follow1, None).await else { let Ok(cha) = Self::cha(&task.from, task.follow, None).await else {
warn!("Paste task partially done: {task:?}"); warn!("Paste task partially done: {task:?}");
break; break;
}; };
if cha.is_orphan() || (cha.is_link() && !task.follow1) { if cha.is_orphan() || (cha.is_link() && !task.follow) {
task.cha = Some(cha); task.cha = Some(cha);
return Ok(self.queue(task.into_link(), NORMAL)); return Ok(self.queue(task.into_link(), NORMAL));
} }

View file

@ -6,13 +6,13 @@ use yazi_shared::{Id, url::UrlBuf};
// --- Paste // --- Paste
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub(crate) struct FileInPaste { pub(crate) struct FileInPaste {
pub(crate) id: Id, pub(crate) id: Id,
pub(crate) from: UrlBuf, pub(crate) from: UrlBuf,
pub(crate) to: UrlBuf, pub(crate) to: UrlBuf,
pub(crate) cha: Option<Cha>, pub(crate) cha: Option<Cha>,
pub(crate) cut: bool, pub(crate) cut: bool,
pub(crate) follow1: bool, pub(crate) follow: bool,
pub(crate) retry: u8, pub(crate) retry: u8,
} }
impl FileInPaste { impl FileInPaste {
@ -23,7 +23,7 @@ impl FileInPaste {
to, to,
cha: Some(cha), cha: Some(cha),
cut: self.cut, cut: self.cut,
follow1: self.follow1, follow: self.follow,
retry: self.retry, retry: self.retry,
} }
} }

View file

@ -97,12 +97,12 @@ impl Scheduler {
}); });
let file = self.file.clone(); let file = self.file.clone();
let follow1 = !from.scheme().covariant(to.scheme()); let follow = !from.scheme().covariant(to.scheme());
self.send_micro(id, LOW, async move { self.send_micro(id, LOW, async move {
if !force { if !force {
to = unique_name(to, must_be_dir(&from)).await?; to = unique_name(to, must_be_dir(&from)).await?;
} }
file.paste(FileInPaste { id, from, to, cha: None, cut: true, follow1, retry: 0 }).await file.paste(FileInPaste { id, from, to, cha: None, cut: true, follow, retry: 0 }).await
}); });
} }
@ -118,12 +118,12 @@ impl Scheduler {
} }
let file = self.file.clone(); let file = self.file.clone();
let follow1 = follow || !from.scheme().covariant(to.scheme()); let follow = follow || !from.scheme().covariant(to.scheme());
self.send_micro(id, LOW, async move { self.send_micro(id, LOW, async move {
if !force { if !force {
to = unique_name(to, must_be_dir(&from)).await?; to = unique_name(to, must_be_dir(&from)).await?;
} }
file.paste(FileInPaste { id, from, to, cha: None, cut: false, follow1, retry: 0 }).await file.paste(FileInPaste { id, from, to, cha: None, cut: false, follow, retry: 0 }).await
}); });
} }