Skip to content

Commit

Permalink
v0.2.10 add chunk_xl size
Browse files Browse the repository at this point in the history
  • Loading branch information
Mon-ius committed May 14, 2024
1 parent 6680d60 commit 1ed81c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hfd-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hfd-cli"
version = "0.2.9"
version = "0.2.10"
edition = "2021"

[dependencies]
Expand Down
11 changes: 9 additions & 2 deletions hfd-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use tokio::io::{AsyncSeekExt, SeekFrom};
use futures::StreamExt;

const CHUNK_SIZE: usize = 100_000_000;
const CHUNK_SIZE_XL: usize = 10_000_000_000;

#[derive(Debug)]
pub struct HfURL {
Expand Down Expand Up @@ -97,7 +98,7 @@ async fn download_chunk(
let mut stream = response.bytes_stream();

let mut file = tokio::fs::OpenOptions::new().write(true).open(path).await?;
file.seek(SeekFrom::Start(s as u64)).await?;
file.seek(SeekFrom::Start(s as u64)).await?;
while let Some(chunk) = stream.next().await {
let chunk = chunk?;
tokio::io::copy(&mut chunk.as_ref(), &mut file).await?;
Expand Down Expand Up @@ -266,7 +267,13 @@ impl HfClient {
let url = self.hf_url.path(&file);
let path = self.root.join(&file);
let headers = self.headers.clone();
tasks.push(download(headers, url, path, CHUNK_SIZE));
if self.hf_url.endpoint.contains("face"){
tasks.push(download(headers, url, path, CHUNK_SIZE));
}
else {
tasks.push(download(headers, url, path, CHUNK_SIZE_XL));
}

}

while let Some(handle) = tasks.next().await {
Expand Down

0 comments on commit 1ed81c1

Please sign in to comment.