| 404 | } |
| 405 | |
| 406 | async fn change_directory( |
| 407 | insecure_ftp_stream: Option<&mut AsyncFtpStream>, |
| 408 | secure_ftp_stream: Option<&mut AsyncNativeTlsFtpStream>, |
| 409 | file_path: Option<&str>, |
| 410 | ) -> Result<(), String> { |
| 411 | if let Some(path) = file_path { |
| 412 | if let Some(ftp_stream) = secure_ftp_stream { |
| 413 | match ftp_stream.cwd(path).await { |
| 414 | Ok(_) => {} |
| 415 | Err(err) => { |
| 416 | return Err(format!("Failed to change directory to {}: {}", path, err)); |
| 417 | } |
| 418 | } |
| 419 | } else if let Some(ftp_stream) = insecure_ftp_stream { |
| 420 | match ftp_stream.cwd(path).await { |
| 421 | Ok(_) => {} |
| 422 | Err(err) => { |
| 423 | return Err(format!("Failed to change directory to {}: {}", path, err)); |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | Ok(()) |
| 430 | } |
| 431 | |
| 432 | async fn create_directories_if_non_existent( |
| 433 | insecure_ftp_stream: Option<&mut AsyncFtpStream>, |