Open tadghh opened 5 months ago
Ever figure this out?
Ever figure this out?
yeah decided to not use async
pub async fn download_file(file_name: String, ftp_path: String) -> Result<(), suppaftp::FtpError> {
let ftp_server = env!("BLOG_FTP_ADDRESS");
let mut ftp_stream = FtpStream::connect(ftp_server).unwrap();
ftp_stream
.login(env!("BLOG_FTP_USERNAME"), env!("BLOG_FTP_PASSWORD"))
.expect("FTP Login failed");
ftp_stream
.cwd(ftp_path)
.expect("FTP failed to change working directory");
let mut ftp_download_buffer = Vec::new();
ftp_stream
.retr(&file_name, |stream| {
stream
.read_to_end(&mut ftp_download_buffer)
.map_err(|e| FtpError::ConnectionError(e))
})
.expect(&format!(
"Failed to write stream{}",
ftp_stream.pwd().unwrap()
));
ftp_stream.quit().expect("FTP Failed to quit");
let file_path = get_cache_dir().join(file_name);
write(file_path, ftp_download_buffer)
.await
.expect("Tauri failed to write to cache");
Ok(())
}
I'm trying to download a single file using the retr function, but I can't seem to grasp the
reader: F
part. I attempted to get ChatGPT to explain but that resulted in "dyn async_std::io::Read
cannot be unpinned".Here is what I have so far, it contains the issue mentioned
I'm still learning so perhaps im missing something silly. Thanks in advance.