You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am hoping you can help me with a strange issue some of my users are experiencing. I am essentially just looping through a list of files to download. Some users have reported that the download will begin, but eventually will stall out and not continue. In the attached logs, you can see the downloads start, but the user reported waiting for about 15 minutes with no response (the files are not large, and it is all on a LAN, so should not be network issue). I am doing so in batches of 10 via tokio::sync::Semaphore, but even when I was just looping through one by one, this issue seemed to pop up here and there.
Am I doing anything wrong in my code? At one point I was using the standard ftp_stream.retr_as_buffer method, but I switched to ftp_stream.retr_as_stream to see if that would help, but it does not seem to have made a difference. As you can tell from the logs, I never make it out of ap_ftp_copy by Ok or Err.
Any advice is welcome!
Code
//////////////////////////////////////////////////////////////////info!("Copying POS from AP...");
progress_bar.set_message(format!("{} (Copying POS from AP...)", date_string.clone()));let pos_ap_path = Path::new(&parent_path).join("pos_ap");let permits = Arc::new(Semaphore::new(10));let futures = date.pos.ap.clone().into_iter().map(|pos| {let permits = Arc::clone(&permits);let pos_ap_path_clone = pos_ap_path.clone();let pos_clone:String = pos.clone();asyncmove{let permit = match permits.acquire().await{Ok(permit) => permit,Err(e) => {returnErr(CommandError{message:format!("Could not acquire permit to copy {}",
pos_clone.clone()),cause: e.to_string(),})}};info!("[pos_ap] Copying {}", pos_clone);matchap_ftp_copy(pos_clone.as_str(),&pos_ap_path_clone).await{Ok(message) => {info!("[pos_ap] Successfully copied {}", pos_clone);drop(permit);
progress_bar.inc(1);Ok(message)}Err(e) => returnErr(e),}}});let results = future::join_all(futures).await;for result in results {match result {Ok(message) => debug!("{}", message),Err(e) => returnErr(e),}}//////////////////////////////////////////////////////////////////pubasyncfnap_ftp_copy(file:&str,dest:&PathBuf) -> Result<String,CommandError>{if async_std::fs::metadata(&dest).await.is_err(){debug!(" mkdir: {:?}", dest);match async_std::fs::create_dir_all(&dest).await{Ok(()) => (),Err(e) => {returnErr(CommandError{message:format!("Problem creating dirs for {:?}", dest),cause: e.to_string(),})}};}letmut new_file = match async_std::fs::OpenOptions::new().write(true).create(true).truncate(true).open(dest.join(file)).await{Ok(new_file) => new_file,Err(e) => {returnErr(CommandError{message:format!("Problem creating file for {}", file),cause: e.to_string(),})}};letmut ftp_stream = match ap_ftp::connect_async().await{Ok(ftp_stream_async) => ftp_stream_async,Err(e) => returnErr(e),};letmut file_stream = match ftp_stream.retr_as_stream(file).await{Ok(file_stream) => file_stream,Err(e) => {returnErr(CommandError{message:format!("Problem creating stream for file {}", file),cause: e.to_string(),})}};let copy_response = match async_std::io::copy(&mut file_stream,&mut new_file).await{Ok(_bytes) => {format!("Successfully copied file: {}", file)}Err(e) => {returnErr(CommandError{message:format!("Problem writing file {} from stream", file),cause: e.to_string(),})}};match ftp_stream.finalize_retr_stream(file_stream).await{Ok(()) => (),Err(e) => {returnErr(CommandError{message:format!("Problem finalizing stream for file {}", file),cause: e.to_string(),})}}match ftp_stream.quit().await{Ok(()) => Ok(copy_response),Err(e) => {warn!("Could not close FTP session in discover: {}", e.to_string());returnOk(copy_response);}}}
Hello, thanks for the great crate!
I am hoping you can help me with a strange issue some of my users are experiencing. I am essentially just looping through a list of files to download. Some users have reported that the download will begin, but eventually will stall out and not continue. In the attached logs, you can see the downloads start, but the user reported waiting for about 15 minutes with no response (the files are not large, and it is all on a LAN, so should not be network issue). I am doing so in batches of 10 via
tokio::sync::Semaphore
, but even when I was just looping through one by one, this issue seemed to pop up here and there.Am I doing anything wrong in my code? At one point I was using the standard
ftp_stream.retr_as_buffer
method, but I switched toftp_stream.retr_as_stream
to see if that would help, but it does not seem to have made a difference. As you can tell from the logs, I never make it out ofap_ftp_copy
by Ok or Err.Any advice is welcome!
Code
Log
ap_ftp.log
The text was updated successfully, but these errors were encountered: