summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--installer-downloader/Cargo.toml1
-rw-r--r--installer-downloader/src/controller.rs10
3 files changed, 10 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index e9d1acf67a..888450184f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2130,6 +2130,7 @@ dependencies = [
"native-windows-gui",
"nsvg",
"objc_id",
+ "rand 0.8.5",
"serde",
"tokio",
"windows-sys 0.52.0",
diff --git a/installer-downloader/Cargo.toml b/installer-downloader/Cargo.toml
index 79c7066074..029a10dcbb 100644
--- a/installer-downloader/Cargo.toml
+++ b/installer-downloader/Cargo.toml
@@ -19,6 +19,7 @@ windows-sys = { version = "0.52.0", features = ["Win32_System", "Win32_System_Li
anyhow = "1.0"
tokio = { version = "1", features = ["full"] }
async-trait = "0.1"
+rand = { version = "0.8.5" }
serde = { workspace = true, features = ["derive"] }
mullvad-update = { path = "../mullvad-update" }
diff --git a/installer-downloader/src/controller.rs b/installer-downloader/src/controller.rs
index 09860ec56c..103f06a3f5 100644
--- a/installer-downloader/src/controller.rs
+++ b/installer-downloader/src/controller.rs
@@ -9,6 +9,7 @@ use mullvad_update::{
app::{self, AppDownloader},
version::{Version, VersionArchitecture, VersionInfo, VersionParameters},
};
+use rand::seq::SliceRandom;
use std::future::Future;
use std::path::PathBuf;
@@ -313,8 +314,7 @@ async fn handle_action_messages<D, A, DirProvider>(
}
};
- // TODO: Select appropriate URLs
- let Some(app_url) = selected_version.urls.first() else {
+ let Some(app_url) = select_cdn_url(&selected_version.urls) else {
return;
};
let app_version = selected_version.version.clone();
@@ -386,6 +386,12 @@ async fn handle_action_messages<D, A, DirProvider>(
}
}
+/// Select a mirror to download from
+/// Currently, the selection is random
+fn select_cdn_url(urls: &[String]) -> Option<&str> {
+ urls.choose(&mut rand::thread_rng()).map(String::as_str)
+}
+
fn format_latest_version(version: &Version) -> String {
format!("{}: {}", resource::LATEST_VERSION_PREFIX, version.version)
}