summaryrefslogtreecommitdiffstatshomepage
path: root/src-tauri
diff options
context:
space:
mode:
authorHsiangNianian <i@jyunko.cn>2026-01-13 15:56:32 +0800
committerHsiangNianian <i@jyunko.cn>2026-01-13 15:56:32 +0800
commitd247a02cd9656b7ca15128e517c8e995af66903a (patch)
tree629393ff350c213529d7fd14409532c84fa63c3b /src-tauri
parent66f7825ed9638606665b9e61c6f8132de013da14 (diff)
downloadDropOut-d247a02cd9656b7ca15128e517c8e995af66903a.tar.gz
DropOut-d247a02cd9656b7ca15128e517c8e995af66903a.zip
feat: refactor download logic to use chunking for response handling
Diffstat (limited to 'src-tauri')
-rw-r--r--src-tauri/src/core/downloader.rs11
1 files changed, 2 insertions, 9 deletions
diff --git a/src-tauri/src/core/downloader.rs b/src-tauri/src/core/downloader.rs
index 0ba9aec..33404e9 100644
--- a/src-tauri/src/core/downloader.rs
+++ b/src-tauri/src/core/downloader.rs
@@ -72,21 +72,14 @@ pub async fn download_files(window: Window, tasks: Vec<DownloadTask>) -> Result<
}
match client.get(&task.url).send().await {
- Ok(resp) => {
+ Ok(mut resp) => {
let total_size = resp.content_length().unwrap_or(0);
let mut file = match tokio::fs::File::create(&task.path).await {
Ok(f) => f,
Err(e) => return Err(format!("Create file error: {}", e)),
};
- // reqwest::Response::bytes_stream() is only available if the 'stream' feature is enabled
- // But we used 'blocking' and 'json'. We should add 'stream' feature to Cargo.toml?
- // Or just use chunk().
- // Actually, let's just create a loop if stream feature is missing or use chunk() manually if blocking is used?
- // Wait, we are in async context. 'reqwest' dependency in Cargo.toml has 'json', 'blocking'
- // We need 'stream' feature for .bytes_stream()
-
- // Let's use loop with chunk()
+ let mut downloaded: u64 = 0;
loop {
match resp.chunk().await {
Ok(Some(chunk)) => {