Skip to content

Commit d2909b5

Browse files
committed
Fix downloading
1 parent e616f4b commit d2909b5

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

server/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ impl hyper::body::Body for BodyKind {
173173
let mut chunk: [u8; 4096] = [0u8; 4096];
174174
if let Ok(n) = h.read(&mut chunk) {
175175
let chunk = Bytes::copy_from_slice(&chunk[..n]);
176+
log::debug!("Yielding chunk of length {}", chunk.len());
176177
Poll::Ready(Some(Ok(Frame::data(chunk))))
177178
} else {
178179
Poll::Ready(None)

src/client.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::io::Read;
77
use std::io::Write;
88
use std::net::TcpStream;
99
use std::path::Path;
10+
use xz2::write::XzDecoder;
1011

1112
#[derive(Clone)]
1213
pub struct Client {
@@ -64,7 +65,10 @@ impl Client {
6465
}
6566

6667
pub fn download_raw(&self, krate: &Crate) -> Result<Vec<u8>> {
67-
self.download(&self.tool.raw_crate_path(krate))
68+
let bytes = self.download(&self.tool.raw_crate_path(krate))?;
69+
let mut decoder = XzDecoder::new(Vec::new());
70+
decoder.write_all(&bytes)?;
71+
Ok(decoder.finish()?)
6872
}
6973

7074
fn download(&self, key: &str) -> Result<Vec<u8>> {

0 commit comments

Comments
 (0)