feat: prioritize symbolic links when cutting remote files (#3412)

This commit is contained in:
三咲雅 misaki masa 2025-12-07 18:00:49 +08:00 committed by GitHub
parent d2e9e72684
commit 9ae8b90d23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 87 additions and 21 deletions

View file

@ -0,0 +1,4 @@
#[derive(Clone, Copy, Debug)]
pub struct Capabilities {
pub symlink: bool,
}

View file

@ -3,7 +3,7 @@ use std::{io, path::Path, sync::Arc};
use tokio::sync::mpsc;
use yazi_shared::{path::{AsPath, PathBufDyn}, scheme::SchemeKind, strand::AsStrand, url::{Url, UrlBuf, UrlCow}};
use crate::{cha::Cha, path::absolute_url, provider::{Attrs, Provider}};
use crate::{cha::Cha, path::absolute_url, provider::{Attrs, Capabilities, Provider}};
#[derive(Clone)]
pub struct Local<'a> {
@ -25,6 +25,9 @@ impl<'a> Provider for Local<'a> {
tokio::fs::canonicalize(self.path).await.map(Into::into)
}
#[inline]
fn capabilities(&self) -> Capabilities { Capabilities { symlink: true } }
async fn casefold(&self) -> io::Result<UrlBuf> {
super::casefold(self.path).await.map(Into::into)
}

View file

@ -1,3 +1,3 @@
yazi_macro::mod_pub!(local);
yazi_macro::mod_flat!(attrs traits);
yazi_macro::mod_flat!(attrs capabilities traits);

View file

@ -4,7 +4,7 @@ use tokio::{io::{AsyncRead, AsyncSeek, AsyncWrite, AsyncWriteExt}, sync::mpsc};
use yazi_macro::ok_or_not_found;
use yazi_shared::{path::{AsPath, PathBufDyn}, strand::{AsStrand, StrandCow}, url::{AsUrl, Url, UrlBuf}};
use crate::{cha::{Cha, ChaType}, provider::Attrs};
use crate::{cha::{Cha, ChaType}, provider::{Attrs, Capabilities}};
pub trait Provider: Sized {
type File: AsyncRead + AsyncSeek + AsyncWrite + Unpin;
@ -17,6 +17,8 @@ pub trait Provider: Sized {
fn canonicalize(&self) -> impl Future<Output = io::Result<UrlBuf>>;
fn capabilities(&self) -> Capabilities;
fn casefold(&self) -> impl Future<Output = io::Result<UrlBuf>>;
fn copy<P>(&self, to: P, attrs: Attrs) -> impl Future<Output = io::Result<u64>>