mirror of
https://github.com/sxyazi/yazi.git
synced 2026-05-13 08:16:40 +00:00
feat: remote file management (#3396)
This commit is contained in:
parent
878b74acb7
commit
c7739c5941
19 changed files with 105 additions and 62 deletions
|
|
@ -45,7 +45,7 @@ pub(super) fn copy_with_progress_impl(
|
|||
};
|
||||
|
||||
let chunks = (cha.len + 10485760 - 1) / 10485760;
|
||||
let result = futures::stream::iter(0..chunks)
|
||||
let mut result = futures::stream::iter(0..chunks)
|
||||
.map(|i| {
|
||||
let acc_ = acc_.clone();
|
||||
let (from, to) = (from.clone(), to.clone());
|
||||
|
|
@ -79,24 +79,22 @@ pub(super) fn copy_with_progress_impl(
|
|||
copied += n as u64;
|
||||
acc_.fetch_add(n as u64, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
dist.flush().await?;
|
||||
if i == chunks - 1 {
|
||||
dist.get_ref().set_attrs(attrs).await.ok();
|
||||
}
|
||||
dist.shutdown().await.ok();
|
||||
|
||||
if copied == take {
|
||||
Ok(())
|
||||
} else {
|
||||
if copied != take {
|
||||
Err(io::Error::other(format!(
|
||||
"short copy for chunk {i}: copied {copied} bytes, expected {take}"
|
||||
)))
|
||||
} else if i == chunks - 1 {
|
||||
Ok(Some(dist.into_inner()))
|
||||
} else {
|
||||
dist.shutdown().await.ok();
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
})
|
||||
.buffer_unordered(3)
|
||||
.try_for_each(|_| async { Ok(()) })
|
||||
.try_fold(None, |first, file| async { Ok(first.or(file)) })
|
||||
.await;
|
||||
|
||||
let n = acc_.swap(0, Ordering::SeqCst);
|
||||
|
|
@ -104,6 +102,11 @@ pub(super) fn copy_with_progress_impl(
|
|||
prog_tx_.send(Ok(n)).await.ok();
|
||||
}
|
||||
|
||||
if let Ok(Some(file)) = &mut result {
|
||||
file.set_attrs(attrs).await.ok();
|
||||
file.shutdown().await.ok();
|
||||
}
|
||||
|
||||
if let Err(e) = result {
|
||||
prog_tx_.send(Err(e)).await.ok();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -164,9 +164,11 @@ impl Conn {
|
|||
russh::client::connect(pref, (self.config.host.as_str(), self.config.port), self).await?;
|
||||
|
||||
for key in keys {
|
||||
match session.authenticate_publickey_with(&self.config.user, key, None, &mut agent).await {
|
||||
let hash_alg = session.best_supported_rsa_hash().await?.flatten();
|
||||
match session.authenticate_publickey_with(&self.config.user, key, hash_alg, &mut agent).await
|
||||
{
|
||||
Ok(result) if result.success() => return Ok(session),
|
||||
Ok(_) => {}
|
||||
Ok(result) => tracing::debug!("Identity agent authentication failed: {result:?}"),
|
||||
Err(e) => tracing::error!("Identity agent authentication error: {e}"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue