From 02f5fca5655cc24bf0cefadb86ca0378e47d5b88 Mon Sep 17 00:00:00 2001 From: Donald Knuth Date: Sat, 3 Sep 2022 15:12:47 -0400 Subject: [PATCH] Still broken --- src/client.rs | 18 +++++++++++------- src/file.rs | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/client.rs b/src/client.rs index 052d405..8a023c5 100644 --- a/src/client.rs +++ b/src/client.rs @@ -43,9 +43,7 @@ pub async fn receive(password: &String) -> Result<()> { let (socket, key) = handshake.negotiate(socket, s1).await?; let mut connection = Connection::new(socket, key); // Wait for offered files, respond with desired files - let desired_files = request_specific_files(&mut connection).await?; - // Create files - let std_file_handles = create_or_find_files(desired_files).await?; + let std_file_handles = request_specific_files(&mut connection).await?; // Download them connection.download_files(std_file_handles).await?; return Ok(()); @@ -72,7 +70,7 @@ pub async fn offer_files( } } -pub async fn request_specific_files(conn: &mut Connection) -> Result> { +pub async fn request_specific_files(conn: &mut Connection) -> Result> { // Wait for offer message let offer_message = conn.await_msg().await?; let offered_files: Vec = match offer_message { @@ -81,17 +79,18 @@ pub async fn request_specific_files(conn: &mut Connection) -> Result) -> Result> { @@ -110,6 +109,11 @@ pub async fn create_or_find_files(desired_files: Vec) -> Result File::create(filename).await?, }; let metadata = file.metadata().await?; + println!( + "Current len: {:?}, Full Size: {:?}", + metadata.len(), + desired_file.size + ); let std_file_handle = StdFileHandle::new(desired_file.id, file, metadata.len(), desired_file.size).await?; v.push(std_file_handle) diff --git a/src/file.rs b/src/file.rs index dec835e..43ed94f 100644 --- a/src/file.rs +++ b/src/file.rs @@ -85,6 +85,7 @@ impl FileHandle { } async fn to_std(self, chunk_header: &ChunkHeader) -> Result { + println!("{:?} requested start?", chunk_header.start); StdFileHandle::new(self.id, self.file, chunk_header.start, self.md.len()).await }