This commit is contained in:
sxyazi 2025-09-28 15:23:24 +08:00
parent a10b9088fc
commit f09129ec46
No known key found for this signature in database
5 changed files with 14 additions and 13 deletions

View file

@ -13,7 +13,7 @@ use yazi_parser::VoidOpt;
use yazi_proxy::{AppProxy, HIDER, TasksProxy}; use yazi_proxy::{AppProxy, HIDER, TasksProxy};
use yazi_shared::{OsStrJoin, event::Data, terminal_clear, url::{Component, UrlBuf}}; use yazi_shared::{OsStrJoin, event::Data, terminal_clear, url::{Component, UrlBuf}};
use yazi_term::tty::TTY; use yazi_term::tty::TTY;
use yazi_vfs::{VfsFile, maybe_exists, provider::{self, must_identical}}; use yazi_vfs::{VfsFile, maybe_exists, provider};
use yazi_watcher::WATCHER; use yazi_watcher::WATCHER;
use crate::{Actor, Ctx}; use crate::{Actor, Ctx};
@ -122,7 +122,7 @@ impl BulkRename {
selected[n.0].components().take(root).chain([Component::Normal(&n)]).collect(), selected[n.0].components().take(root).chain([Component::Normal(&n)]).collect(),
); );
if maybe_exists(&new).await && !must_identical(&old, &new).await { if maybe_exists(&new).await && !provider::must_identical(&old, &new).await {
failed.push((o, n, anyhow!("Destination already exists"))); failed.push((o, n, anyhow!("Destination already exists")));
} else if let Err(e) = provider::rename(&old, &new).await { } else if let Err(e) = provider::rename(&old, &new).await {
failed.push((o, n, e.into())); failed.push((o, n, e.into()));

View file

@ -14,6 +14,7 @@ pub fn skip_url(url: &UrlBuf, n: usize) -> Cow<'_, OsStr> {
#[cfg(windows)] #[cfg(windows)]
pub fn backslash_to_slash(p: &std::path::Path) -> Cow<'_, std::path::Path> { pub fn backslash_to_slash(p: &std::path::Path) -> Cow<'_, std::path::Path> {
use std::{ffi::OsString, path::PathBuf};
let bytes = p.as_os_str().as_encoded_bytes(); let bytes = p.as_os_str().as_encoded_bytes();
// Fast path to skip if there are no backslashes // Fast path to skip if there are no backslashes
@ -30,7 +31,7 @@ pub fn backslash_to_slash(p: &std::path::Path) -> Cow<'_, std::path::Path> {
for &b in rest { for &b in rest {
out.push(if b == b'\\' { b'/' } else { b }); out.push(if b == b'\\' { b'/' } else { b });
} }
Cow::Owned(std::path::PathBuf::from(unsafe { OsString::from_encoded_bytes_unchecked(out) })) Cow::Owned(PathBuf::from(unsafe { OsString::from_encoded_bytes_unchecked(out) }))
} }
#[cfg(test)] #[cfg(test)]

View file

@ -15,9 +15,9 @@ impl FileBuilder for Gate {
self self
} }
fn cha(&mut self, cha: Cha) -> &mut Self { fn cha(&mut self, _cha: Cha) -> &mut Self {
#[cfg(unix)] #[cfg(unix)]
self.0.mode(cha.mode.bits() as _); self.0.mode(_cha.mode.bits() as _);
self self
} }

View file

@ -1,4 +1,4 @@
use std::fs::{FileTimes, Permissions}; use std::fs::FileTimes;
use crate::cha::Cha; use crate::cha::Cha;
@ -31,10 +31,10 @@ impl From<Cha> for FileTimes {
} }
#[cfg(unix)] #[cfg(unix)]
impl From<Cha> for Permissions { impl From<Cha> for std::fs::Permissions {
fn from(cha: Cha) -> Self { fn from(cha: Cha) -> Self {
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
Permissions::from_mode(cha.mode.bits() as _) std::fs::Permissions::from_mode(cha.mode.bits() as _)
} }
} }

View file

@ -9,7 +9,7 @@ use yazi_dds::Pump;
use yazi_parser::{app::PluginOpt, tasks::ProcessExecOpt}; use yazi_parser::{app::PluginOpt, tasks::ProcessExecOpt};
use yazi_proxy::TasksProxy; use yazi_proxy::TasksProxy;
use yazi_shared::{Id, Throttle, url::UrlBuf}; use yazi_shared::{Id, Throttle, url::UrlBuf};
use yazi_vfs::{provider, unique_name}; use yazi_vfs::{must_be_dir, provider, unique_name};
use super::{Ongoing, TaskOp}; use super::{Ongoing, TaskOp};
use crate::{HIGH, LOW, NORMAL, TaskIn, TaskOps, TaskOut, file::{File, FileInDelete, FileInHardlink, FileInLink, FileInPaste, FileInTrash, FileOutDelete, FileOutHardlink, FileOutPaste, FileProgDelete, FileProgHardlink, FileProgLink, FileProgPaste, FileProgTrash}, plugin::{Plugin, PluginInEntry, PluginProgEntry}, prework::{Prework, PreworkInFetch, PreworkInLoad, PreworkInSize, PreworkProgFetch, PreworkProgLoad, PreworkProgSize}, process::{Process, ProcessInBg, ProcessInBlock, ProcessInOrphan, ProcessOutBg, ProcessOutBlock, ProcessOutOrphan, ProcessProgBg, ProcessProgBlock, ProcessProgOrphan}}; use crate::{HIGH, LOW, NORMAL, TaskIn, TaskOps, TaskOut, file::{File, FileInDelete, FileInHardlink, FileInLink, FileInPaste, FileInTrash, FileOutDelete, FileOutHardlink, FileOutPaste, FileProgDelete, FileProgHardlink, FileProgLink, FileProgPaste, FileProgTrash}, plugin::{Plugin, PluginInEntry, PluginProgEntry}, prework::{Prework, PreworkInFetch, PreworkInLoad, PreworkInSize, PreworkProgFetch, PreworkProgLoad, PreworkProgSize}, process::{Process, ProcessInBg, ProcessInBlock, ProcessInOrphan, ProcessOutBg, ProcessOutBlock, ProcessOutOrphan, ProcessProgBg, ProcessProgBlock, ProcessProgOrphan}};
@ -99,7 +99,7 @@ impl Scheduler {
let file = self.file.clone(); let file = self.file.clone();
self.send_micro(id, LOW, async move { self.send_micro(id, LOW, async move {
if !force { if !force {
to = unique_name(to, yazi_vfs::must_be_dir(&from)).await?; to = unique_name(to, must_be_dir(&from)).await?;
} }
file.paste(FileInPaste { id, from, to, cha: None, cut: true, follow: false, retry: 0 }).await file.paste(FileInPaste { id, from, to, cha: None, cut: true, follow: false, retry: 0 }).await
}); });
@ -121,7 +121,7 @@ impl Scheduler {
let file = self.file.clone(); let file = self.file.clone();
self.send_micro(id, LOW, async move { self.send_micro(id, LOW, async move {
if !force { if !force {
to = unique_name(to, yazi_vfs::must_be_dir(&from)).await?; to = unique_name(to, must_be_dir(&from)).await?;
} }
file.paste(FileInPaste { id, from, to, cha: None, cut: false, follow, retry: 0 }).await file.paste(FileInPaste { id, from, to, cha: None, cut: false, follow, retry: 0 }).await
}); });
@ -137,7 +137,7 @@ impl Scheduler {
let file = self.file.clone(); let file = self.file.clone();
self.send_micro(id, LOW, async move { self.send_micro(id, LOW, async move {
if !force { if !force {
to = unique_name(to, yazi_vfs::must_be_dir(&from)).await?; to = unique_name(to, must_be_dir(&from)).await?;
} }
file.link(FileInLink { id, from, to, cha: None, resolve: false, relative, delete: false }) file.link(FileInLink { id, from, to, cha: None, resolve: false, relative, delete: false })
}); });
@ -159,7 +159,7 @@ impl Scheduler {
let file = self.file.clone(); let file = self.file.clone();
self.send_micro(id, LOW, async move { self.send_micro(id, LOW, async move {
if !force { if !force {
to = unique_name(to, yazi_vfs::must_be_dir(&from)).await?; to = unique_name(to, must_be_dir(&from)).await?;
} }
file.hardlink(FileInHardlink { id, from, to, cha: None, follow }).await file.hardlink(FileInHardlink { id, from, to, cha: None, follow }).await
}); });