Skip to content

Commit

Permalink
🧩 Refactor(Downloader): Remove blocked methods in reqwest and forma…
Browse files Browse the repository at this point in the history
…tted `Cargo.toml`
  • Loading branch information
Dynesshely committed Jun 29, 2024
1 parent a9de442 commit 94bdca7
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 92 deletions.
141 changes: 119 additions & 22 deletions KitX_Installer_Egui/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 9 additions & 17 deletions KitX_Installer_Egui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@ publish = false
edition = "2021"
build = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
windows = []

[dependencies]
eframe = "0.27.2"
env_logger = "0.11.3"
reqwest = { version = "0.12.4", features = ["blocking"] }
# tokio = { version = "1.29.1", features = ["full"] }
regex = "1.10.4"
reqwest = "0.12.5"
regex = "1.10.5"
arguments = "0.7.2"
winreg = { version = "0.52.0", optional = true }
image = "0.25.1"
msgbox = "0.7.0"
native-dialog = "0.7.0"
# compress-tools = "0.14.3"
tokio = { version = "1.38.0", features = ["full"] }

[target.'cfg(windows)'.dependencies]
winreg = "0.52.0"
Expand All @@ -31,18 +28,13 @@ winres = "0.1.12"
static_vcruntime = "2.0.0"

[profile.release]
# Automatically strip symbols from the binary.
strip = true

# Optimize for size.
opt-level = "z"

# Use Link Time Optimization if available.
lto = true

# Use only one codegen unit to allow for better optimizing.
codegen-units = 1
strip = true # Automatically strip symbols from the binary.
opt-level = "z" # Optimize for size.
lto = true # Use Link Time Optimization if available.
codegen-units = 1 # Use only one codegen unit to allow for better optimizing.

[package.metadata.winres]
OriginalFilename = "KitX Installer.exe"
LegalCopyright = "Copyright © Crequency since 2020"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
34 changes: 14 additions & 20 deletions KitX_Installer_Egui/src/data/data_fetcher.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
extern crate reqwest;

pub async fn _fetch_string_async(url: String) -> String {
let resp = reqwest::get(url);
resp.await.unwrap().text().await.unwrap()
}

pub fn fetch_string(url: String, time_out_milliseconds: i32) -> Option<String> {
let response = reqwest::blocking::Client::builder()
.timeout(std::time::Duration::from_millis(time_out_milliseconds as u64))
.build()
.unwrap()
.get(url)
.send();
pub fn fetch_string(url: String) -> Option<String> {
tokio::runtime::Builder::new_multi_thread().enable_all().build().unwrap().block_on(async {
let response = reqwest::get(url).await;

if response.is_err() {
None
} else {
Some(response.unwrap().text().unwrap())
}
if response.is_err() {
None
} else {
Some(response.unwrap().text().await.unwrap())
}
})
}

pub fn fetch_binary(_url: String) -> Vec<u8> {
let response = reqwest::blocking::get(_url).unwrap();
response.bytes().unwrap().to_vec()
pub fn fetch_binary(url: String) -> Vec<u8> {
tokio::runtime::Builder::new_multi_thread().enable_all().build().unwrap().block_on(async {
let response = reqwest::get(url).await;
response.unwrap().bytes().await.unwrap().to_vec()
})
}
Loading

0 comments on commit 94bdca7

Please sign in to comment.