This commit is contained in:
sxyazi 2025-09-21 11:33:06 +08:00
parent ccbe368dc5
commit ff4644c0e5
No known key found for this signature in database

View file

@ -174,33 +174,35 @@ impl deadpool::managed::Manager for Sftp {
// FIXME: remove the hardcoded test values // FIXME: remove the hardcoded test values
async fn create(&self) -> Result<Self::Type, Self::Error> { async fn create(&self) -> Result<Self::Type, Self::Error> {
async fn inner(sftp: Sftp) -> anyhow::Result<yazi_sftp::Operator> { todo!()
let config = Arc::new(russh::client::Config::default()); // async fn inner(sftp: Sftp) -> anyhow::Result<yazi_sftp::Operator> {
let mut session = russh::client::connect(config, ("127.0.0.1", 22), sftp).await?; // let config = Arc::new(russh::client::Config::default());
// let mut session = russh::client::connect(config, ("127.0.0.1", 22),
// sftp).await?;
let mut agent = russh::keys::agent::client::AgentClient::connect_uds( // let mut agent = russh::keys::agent::client::AgentClient::connect_uds(
"/Users/ika/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock", // "/Users/ika/Library/Group
) // Containers/2BUA8C4S2C.com.1password/t/agent.sock", )
.await?; // .await?;
let mut keys = agent.request_identities().await?; // let mut keys = agent.request_identities().await?;
if !session // if !session
.authenticate_publickey_with("root", keys.remove(0), None, &mut agent) // .authenticate_publickey_with("root", keys.remove(0), None, &mut agent)
.await? // .await?
.success() // .success()
{ // {
panic!("auth failed"); // panic!("auth failed");
} // }
let channel = session.channel_open_session().await?; // let channel = session.channel_open_session().await?;
channel.request_subsystem(true, "sftp").await?; // channel.request_subsystem(true, "sftp").await?;
let mut op = yazi_sftp::Operator::make(channel.into_stream()); // let mut op = yazi_sftp::Operator::make(channel.into_stream());
op.init().await?; // op.init().await?;
Ok(op) // Ok(op)
} // }
inner(*self).await.map_err(|e| io::Error::other(e.to_string())) // inner(*self).await.map_err(|e| io::Error::other(e.to_string()))
} }
async fn recycle( async fn recycle(