mirror of
https://github.com/sxyazi/yazi.git
synced 2026-05-13 08:16:40 +00:00
feat: make task post-hooks stateful (#3454)
This commit is contained in:
parent
329c5d28f0
commit
6e3c96289e
12 changed files with 165 additions and 85 deletions
|
|
@ -126,11 +126,12 @@ pub trait Provider: Sized {
|
|||
}
|
||||
}
|
||||
|
||||
fn remove_dir_clean(&self) -> impl Future<Output = ()> {
|
||||
fn remove_dir_clean(&self) -> impl Future<Output = io::Result<()>> {
|
||||
let root = self.url().to_owned();
|
||||
|
||||
async move {
|
||||
let mut stack = vec![(root, false)];
|
||||
let mut result = Ok(());
|
||||
|
||||
while let Some((dir, visited)) = stack.pop() {
|
||||
let Ok(provider) = Self::new(dir.as_url()).await else {
|
||||
|
|
@ -138,7 +139,7 @@ pub trait Provider: Sized {
|
|||
};
|
||||
|
||||
if visited {
|
||||
provider.remove_dir().await.ok();
|
||||
result = provider.remove_dir().await;
|
||||
} else if let Ok(mut it) = provider.read_dir().await {
|
||||
stack.push((dir, true));
|
||||
while let Ok(Some(ent)) = it.next().await {
|
||||
|
|
@ -148,6 +149,7 @@ pub trait Provider: Sized {
|
|||
}
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue