feat: continuing work on downloading files
This commit is contained in:
@@ -16,13 +16,13 @@ pub async fn download_file(
|
||||
remote_file: PathBuf,
|
||||
local_path: PathBuf,
|
||||
) -> anyhow::Result<()> {
|
||||
let mut file = fs::OpenOptions::new().read(true).open(&local_path).await?;
|
||||
let file_size = file.metadata().await?.len();
|
||||
let mut file = fs::OpenOptions::new()
|
||||
.write(true)
|
||||
.create(true)
|
||||
.open(&local_path)
|
||||
.await?;
|
||||
|
||||
let command = Command::StartUploadFile(
|
||||
remote_path,
|
||||
(file_size / FILE_TRANSFER_PACKET_SIZE as u64) + 1,
|
||||
);
|
||||
let command = Command::StartDownloadFile(remote_file);
|
||||
conn.send_command(command).await?;
|
||||
|
||||
let id = loop {
|
||||
|
||||
@@ -215,9 +215,12 @@ pub(super) async fn shell(
|
||||
}),
|
||||
_,
|
||||
) => {
|
||||
if let Err(e) =
|
||||
commands::download::download(Arc::clone(&connection), remote_file, local_path)
|
||||
.await
|
||||
if let Err(e) = commands::download::download_file(
|
||||
Arc::clone(&connection),
|
||||
remote_file,
|
||||
local_path,
|
||||
)
|
||||
.await
|
||||
{
|
||||
eprintln!("{e:?}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user