|
|
@ -370,17 +370,25 @@ async fn dir_create(session: WezSession, path: PathBuf, all: bool) -> io::Result
|
|
|
|
// Keep trying to create a directory, moving up to parent each time a failure happens
|
|
|
|
// Keep trying to create a directory, moving up to parent each time a failure happens
|
|
|
|
let mut failed_paths = Vec::new();
|
|
|
|
let mut failed_paths = Vec::new();
|
|
|
|
let mut cur_path = path.as_path();
|
|
|
|
let mut cur_path = path.as_path();
|
|
|
|
|
|
|
|
let mut first_err = None;
|
|
|
|
loop {
|
|
|
|
loop {
|
|
|
|
let failed = mkdir(&sftp, cur_path.to_path_buf()).await.is_err();
|
|
|
|
match mkdir(&sftp, cur_path.to_path_buf()).await {
|
|
|
|
if failed {
|
|
|
|
Ok(_) => break,
|
|
|
|
failed_paths.push(cur_path);
|
|
|
|
Err(x) => {
|
|
|
|
if let Some(path) = cur_path.parent() {
|
|
|
|
failed_paths.push(cur_path);
|
|
|
|
cur_path = path;
|
|
|
|
if let Some(path) = cur_path.parent() {
|
|
|
|
} else {
|
|
|
|
cur_path = path;
|
|
|
|
return Err(io::Error::from(io::ErrorKind::PermissionDenied));
|
|
|
|
|
|
|
|
|
|
|
|
if first_err.is_none() {
|
|
|
|
|
|
|
|
first_err = Some(x);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return Err(io::Error::new(
|
|
|
|
|
|
|
|
io::ErrorKind::PermissionDenied,
|
|
|
|
|
|
|
|
first_err.unwrap_or(x),
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|