fix: Deep is_parent was wrong and could be escapped (#1801)

* fix: Deep is_parent was wrong and could be escapped

* Update lib.rs
This commit is contained in:
J M
2022-09-15 12:53:56 -06:00
committed by GitHub
parent ca53793e32
commit 2e8bfcc74d
4 changed files with 87 additions and 7 deletions

View File

@@ -773,11 +773,18 @@ mod fns {
child: impl AsRef<Path>,
) -> Result<bool, AnyError> {
let child = {
let mut child_count = 0;
let mut child = child.as_ref();
loop {
let meta = tokio::fs::metadata(child).await;
if meta.is_ok() {
break;
if child.ends_with("..") {
child_count += 1;
} else if child_count > 0 {
child_count -= 1;
} else {
let meta = tokio::fs::metadata(child).await;
if meta.is_ok() {
break;
}
}
child = match child.parent() {
Some(child) => child,