fix: don't use futures for geodb download
This commit is contained in:
Generated
+6
-20
@@ -120,9 +120,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "async-compression"
|
||||
version = "0.4.22"
|
||||
version = "0.4.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59a194f9d963d8099596278594b3107448656ba73831c9d8c783e613ce86da64"
|
||||
checksum = "b37fc50485c4f3f736a4fb14199f6d5f5ba008d7f28fe710306c92780f004c07"
|
||||
dependencies = [
|
||||
"brotli",
|
||||
"flate2",
|
||||
@@ -199,9 +199,9 @@ checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
|
||||
|
||||
[[package]]
|
||||
name = "brotli"
|
||||
version = "7.0.0"
|
||||
version = "8.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd"
|
||||
checksum = "cf19e729cdbd51af9a397fb9ef8ac8378007b797f8273cfbfdf45dcaa316167b"
|
||||
dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
"alloc-stdlib",
|
||||
@@ -210,9 +210,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "brotli-decompressor"
|
||||
version = "4.0.3"
|
||||
version = "5.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a334ef7c9e23abf0ce748e8cd309037da93e606ad52eb372e4ce327a0dcfbdfd"
|
||||
checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03"
|
||||
dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
"alloc-stdlib",
|
||||
@@ -1700,7 +1700,6 @@ dependencies = [
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"wasm-streams",
|
||||
"web-sys",
|
||||
"webpki-roots",
|
||||
"windows-registry",
|
||||
@@ -2502,19 +2501,6 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-streams"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.77"
|
||||
|
||||
@@ -40,7 +40,6 @@ reqwest = { version = "=0.12.15", default-features = false, features = [
|
||||
"macos-system-configuration",
|
||||
"rustls-tls",
|
||||
"socks",
|
||||
"stream",
|
||||
] }
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
@@ -53,7 +52,6 @@ reqwest = { version = "=0.12.15", default-features = false, features = [
|
||||
"macos-system-configuration",
|
||||
"rustls-tls",
|
||||
"socks",
|
||||
"stream",
|
||||
] }
|
||||
|
||||
[profile.release]
|
||||
|
||||
+6
-5
@@ -1,7 +1,6 @@
|
||||
use std::{io, path::PathBuf};
|
||||
|
||||
use color_eyre::eyre::WrapErr;
|
||||
use futures::StreamExt;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
|
||||
use crate::{
|
||||
@@ -66,7 +65,7 @@ async fn save_etag(
|
||||
}
|
||||
|
||||
async fn save_geodb(
|
||||
response: reqwest::Response,
|
||||
mut response: reqwest::Response,
|
||||
tx: tokio::sync::mpsc::UnboundedSender<Event>,
|
||||
) -> color_eyre::Result<()> {
|
||||
tx.send(Event::App(AppEvent::GeoDbTotal(response.content_length())))?;
|
||||
@@ -76,9 +75,11 @@ async fn save_geodb(
|
||||
tokio::fs::File::create(&geodb_file).await.wrap_err_with(|| {
|
||||
format!("failed to create file {}", geodb_file.display())
|
||||
})?;
|
||||
let mut stream = response.bytes_stream();
|
||||
while let Some(item) = stream.next().await {
|
||||
let chunk = item.wrap_err("failed to read GeoDB response chunk")?;
|
||||
while let Some(chunk) = response
|
||||
.chunk()
|
||||
.await
|
||||
.wrap_err("failed to read GeoDB response chunk")?
|
||||
{
|
||||
file.write_all(&chunk).await.wrap_err_with(|| {
|
||||
format!("failed to write to file {}", geodb_file.display())
|
||||
})?;
|
||||
|
||||
Reference in New Issue
Block a user