-
Notifications
You must be signed in to change notification settings - Fork 2
EIM-112: Added the ping check for mirrors #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alirana01
wants to merge
9
commits into
master
Choose a base branch
from
EIM-112
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fb25292
EIM-112: Added the ping check for mirrors
alirana01 e1fdabf
code cleanup and ai review comments
alirana01 10b9c32
constant extracted for u32
alirana01 5c82fad
Revert "constant extracted for u32"
alirana01 c82dbe9
fix(gui): Latency checks now dont stop the UI interactions
alirana01 84263b0
review comments and moving some mirror latency code to settings.rs in…
alirana01 550bdd1
review comments and logic improvement
alirana01 98cc3be
mutex lock and minor format changes reverted
alirana01 6e94a10
code cleanup on UI
alirana01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ use crate::gui::{ | |
| utils::is_path_empty_or_nonexistent, | ||
| }; | ||
|
|
||
| use log::info; | ||
| use log::{info, warn}; | ||
| use serde_json::{json, Value}; | ||
| use std::{ | ||
| fs::File, | ||
|
|
@@ -37,7 +37,7 @@ pub fn load_settings(app_handle: AppHandle, path: &str) { | |
| }) | ||
| .expect("Failed to load settings"); | ||
| log::debug!("settings after load {:?}", settings); | ||
| }); | ||
| }).expect("Failed to update settings"); | ||
alirana01 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| send_message( | ||
| &app_handle, | ||
| t!("gui.settings.loaded_successfully", path = path).to_string(), | ||
|
|
@@ -207,7 +207,7 @@ pub fn set_versions(app_handle: AppHandle, versions: Vec<String>) -> Result<(), | |
|
|
||
| /// Gets the list of available IDF mirrors | ||
| #[tauri::command] | ||
| pub fn get_idf_mirror_list(app_handle: AppHandle) -> Value { | ||
| pub async fn get_idf_mirror_list(app_handle: AppHandle) -> Value { | ||
| let settings = match get_settings_non_blocking(&app_handle) { | ||
| Ok(s) => s, | ||
| Err(e) => { | ||
|
|
@@ -220,17 +220,22 @@ pub fn get_idf_mirror_list(app_handle: AppHandle) -> Value { | |
| }; | ||
|
|
||
| let mirror = settings.idf_mirror.clone().unwrap_or_default(); | ||
| let mut available_mirrors = idf_im_lib::get_idf_mirrors_list().to_vec(); | ||
| let mut available_mirrors: Vec<String> = idf_im_lib::get_idf_mirrors_list() | ||
|
||
| .iter() | ||
| .map(|s| s.to_string()) | ||
| .collect(); | ||
|
|
||
| if !available_mirrors.contains(&mirror.as_str()) { | ||
| let mut new_mirrors = vec![mirror.as_str()]; | ||
| if !available_mirrors.iter().any(|m| m == &mirror) { | ||
| let mut new_mirrors = vec![mirror.clone()]; | ||
| new_mirrors.extend(available_mirrors); | ||
| available_mirrors = new_mirrors; | ||
| } | ||
|
|
||
| // Pick the lowest-latency mirror to present as selected | ||
| let mirror_latency_map = idf_im_lib::utils::calculate_mirror_latency_map(&available_mirrors).await; | ||
|
|
||
| json!({ | ||
| "mirrors": available_mirrors, | ||
| "selected": mirror, | ||
| "mirrors": mirror_latency_map | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -252,7 +257,7 @@ pub fn set_idf_mirror(app_handle: AppHandle, mirror: String) -> Result<(), Strin | |
|
|
||
| /// Gets the list of available tools mirrors | ||
| #[tauri::command] | ||
| pub fn get_tools_mirror_list(app_handle: AppHandle) -> Value { | ||
| pub async fn get_tools_mirror_list(app_handle: AppHandle) -> Value { | ||
| let settings = match get_settings_non_blocking(&app_handle) { | ||
| Ok(s) => s, | ||
| Err(e) => { | ||
|
|
@@ -265,17 +270,22 @@ pub fn get_tools_mirror_list(app_handle: AppHandle) -> Value { | |
| }; | ||
|
|
||
| let mirror = settings.mirror.clone().unwrap_or_default(); | ||
| let mut available_mirrors = idf_im_lib::get_idf_tools_mirrors_list().to_vec(); | ||
| let mut available_mirrors: Vec<String> = idf_im_lib::get_idf_tools_mirrors_list() | ||
| .iter() | ||
| .map(|s| s.to_string()) | ||
| .collect(); | ||
|
|
||
| if !available_mirrors.contains(&mirror.as_str()) { | ||
| let mut new_mirrors = vec![mirror.as_str()]; | ||
| if !available_mirrors.iter().any(|m| m == &mirror) { | ||
| let mut new_mirrors = vec![mirror.clone()]; | ||
| new_mirrors.extend(available_mirrors); | ||
| available_mirrors = new_mirrors; | ||
| } | ||
|
|
||
| // Pick the lowest-latency mirror to present as selected | ||
| let mirror_latency_map = idf_im_lib::utils::calculate_mirror_latency_map(&available_mirrors).await; | ||
|
|
||
| json!({ | ||
| "mirrors": available_mirrors, | ||
| "selected": mirror, | ||
| "mirrors": mirror_latency_map | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -297,7 +307,7 @@ pub fn set_tools_mirror(app_handle: AppHandle, mirror: String) -> Result<(), Str | |
|
|
||
| /// Gets the list of available tools mirrors | ||
| #[tauri::command] | ||
| pub fn get_pypi_mirror_list(app_handle: AppHandle) -> Value { | ||
| pub async fn get_pypi_mirror_list(app_handle: AppHandle) -> Value { | ||
| let settings = match get_settings_non_blocking(&app_handle) { | ||
| Ok(s) => s, | ||
| Err(e) => { | ||
|
|
@@ -310,17 +320,22 @@ pub fn get_pypi_mirror_list(app_handle: AppHandle) -> Value { | |
| }; | ||
|
|
||
| let mirror = settings.pypi_mirror.clone().unwrap_or_default(); | ||
| let mut available_mirrors = idf_im_lib::get_pypi_mirrors_list().to_vec(); | ||
| let mut available_mirrors: Vec<String> = idf_im_lib::get_pypi_mirrors_list() | ||
| .iter() | ||
| .map(|s| s.to_string()) | ||
| .collect(); | ||
|
|
||
| if !available_mirrors.contains(&mirror.as_str()) { | ||
| let mut new_mirrors = vec![mirror.as_str()]; | ||
| if !available_mirrors.iter().any(|m| m == &mirror) { | ||
| let mut new_mirrors = vec![mirror.clone()]; | ||
| new_mirrors.extend(available_mirrors); | ||
| available_mirrors = new_mirrors; | ||
| } | ||
|
|
||
| // Pick the lowest-latency mirror to present as selected | ||
| let mirror_latency_map = idf_im_lib::utils::calculate_mirror_latency_map(&available_mirrors).await; | ||
|
|
||
| json!({ | ||
| "mirrors": available_mirrors, | ||
| "selected": mirror, | ||
| "mirrors": mirror_latency_map | ||
| }) | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this added dependency is unused if you do not plan to use it remove it