Skip to content

Commit

Permalink
Chunked reading of zip
Browse files Browse the repository at this point in the history
  • Loading branch information
brianreicher committed Oct 11, 2023
1 parent f2cbca9 commit 79e9aed
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ingestion/src/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::fs::File;
use std::path::Path;
use mongo_utils::MongoDriver;
use mongodb::bson::doc;
use std::io::Read;
use zip::read::ZipArchive;

use crate::mongo_utils;
Expand Down Expand Up @@ -41,9 +40,9 @@ impl GitHubDownloader {
let file_path: std::path::PathBuf = Path::new(zip_dirs[index]).join(filename);

let mut response_body = response.bytes().await?;
while let Some(chunk) = response_body.concat() {
let chunk = chunk?;
file_path.write_all(&chunk)?;
while let chunk = response_body.chunks(8) {
let chunk = chunk;
file_path.write_all(&chunk)?; // TODO: write successfully
}

println!("Downloaded: {}", file_path.display());
Expand Down

0 comments on commit 79e9aed

Please sign in to comment.