mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-05-22 17:32:17 +00:00
Improved Rust syntax by Clippy suggestions (#765)
Some checks are pending
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Some checks are pending
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
This commit is contained in:
parent
91cfe8dcd0
commit
9419c4ed44
@ -245,11 +245,9 @@ fn should_open_in_system_browser<R: tauri::Runtime>(webview: &tauri::Webview<R>,
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(current_url) = webview.url() {
|
||||
if same_origin(¤t_url, url) {
|
||||
if let Ok(current_url) = webview.url() && same_origin(¤t_url, url) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
!is_local_host(url.host_str())
|
||||
}
|
||||
@ -415,11 +413,9 @@ pub async fn change_location_to(url: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(parsed_url) = tauri::Url::parse(url) {
|
||||
if is_local_http_url(&parsed_url) {
|
||||
if let Ok(parsed_url) = tauri::Url::parse(url) && is_local_http_url(&parsed_url) {
|
||||
*APPROVED_APP_URL.lock().unwrap() = Some(parsed_url);
|
||||
}
|
||||
}
|
||||
|
||||
let js_location_change = format!("window.location = '{url}';");
|
||||
let main_window = main_window_spawn_clone.lock().unwrap();
|
||||
@ -685,14 +681,12 @@ pub async fn register_shortcut(_token: APIToken, payload: Json<RegisterShortcutR
|
||||
let mut registered_shortcuts = REGISTERED_SHORTCUTS.lock().unwrap();
|
||||
|
||||
// Unregister the old shortcut if one exists for this name:
|
||||
if let Some(old_shortcut) = registered_shortcuts.get(&id) {
|
||||
if !old_shortcut.is_empty() {
|
||||
if let Some(old_shortcut) = registered_shortcuts.get(&id) && !old_shortcut.is_empty() {
|
||||
match shortcut_manager.unregister(old_shortcut.as_str()) {
|
||||
Ok(_) => info!(Source = "Tauri"; "Unregistered old shortcut '{old_shortcut}' for '{}'.", id),
|
||||
Err(error) => warn!(Source = "Tauri"; "Failed to unregister old shortcut '{old_shortcut}': {error}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When the new shortcut is empty, we're done (just unregistering):
|
||||
if new_shortcut.is_empty() {
|
||||
|
||||
@ -87,11 +87,9 @@ fn normalize_locale_tag(locale: &str) -> Option<String> {
|
||||
return None;
|
||||
}
|
||||
|
||||
if let Some(region) = segments.next() {
|
||||
if region.len() == 2 && region.chars().all(|c| c.is_ascii_alphabetic()) {
|
||||
if let Some(region) = segments.next() && region.len() == 2 && region.chars().all(|c| c.is_ascii_alphabetic()) {
|
||||
return Some(format!("{}-{}", language, region.to_ascii_uppercase()));
|
||||
}
|
||||
}
|
||||
|
||||
Some(language)
|
||||
}
|
||||
@ -418,12 +416,11 @@ fn load_policy_values_from_directories(directories: &[PathBuf]) -> HashMap<Strin
|
||||
}
|
||||
|
||||
let secret_path = directory.join(ENTERPRISE_POLICY_SECRET_FILE_NAME);
|
||||
if let Some(secret_values) = read_policy_yaml_mapping(&secret_path) {
|
||||
if let Some(secret) = secret_values.get("config_encryption_secret") {
|
||||
if let Some(secret_values) = read_policy_yaml_mapping(&secret_path)
|
||||
&& let Some(secret) = secret_values.get("config_encryption_secret") {
|
||||
insert_first_non_empty_value(&mut values, "config_encryption_secret", secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
values
|
||||
}
|
||||
|
||||
@ -119,8 +119,8 @@ impl PandocProcessBuilder {
|
||||
let local_installation_root_directory = data_folder.join("pandoc");
|
||||
let executable_name = Self::pandoc_executable_name();
|
||||
|
||||
if local_installation_root_directory.exists() {
|
||||
if let Ok(pandoc_path) = Self::find_executable_in_dir(&local_installation_root_directory, &executable_name) {
|
||||
if local_installation_root_directory.exists()
|
||||
&& let Ok(pandoc_path) = Self::find_executable_in_dir(&local_installation_root_directory, &executable_name) {
|
||||
HAS_LOGGED_PANDOC_PATH.get_or_init(|| {
|
||||
info!(Source = "PandocProcessBuilder"; "Found local Pandoc installation at: '{}'.", pandoc_path.to_string_lossy()
|
||||
);
|
||||
@ -131,7 +131,6 @@ impl PandocProcessBuilder {
|
||||
is_local_installation: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
for candidate in Self::system_pandoc_executable_candidates(&executable_name) {
|
||||
if candidate.exists() && candidate.is_file() {
|
||||
@ -168,13 +167,11 @@ impl PandocProcessBuilder {
|
||||
if let Ok(entries) = fs::read_dir(dir) {
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
if path.is_dir() {
|
||||
if let Ok(found_path) = Self::find_executable_in_dir(&path, executable_name) {
|
||||
if path.is_dir() && let Ok(found_path) = Self::find_executable_in_dir(&path, executable_name) {
|
||||
return Ok(found_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Err("Executable not found".into())
|
||||
}
|
||||
@ -240,8 +237,7 @@ impl PandocProcessBuilder {
|
||||
let runtime_os = std::env::consts::OS;
|
||||
let runtime_arch = std::env::consts::ARCH;
|
||||
|
||||
if let Ok(metadata) = META_DATA.lock() {
|
||||
if let Some(metadata) = metadata.as_ref() {
|
||||
if let Ok(metadata) = META_DATA.lock() && let Some(metadata) = metadata.as_ref() {
|
||||
let metadata_arch = &metadata.architecture;
|
||||
|
||||
// Determine expected OS from metadata:
|
||||
@ -268,7 +264,6 @@ impl PandocProcessBuilder {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Use std::env::consts::OS for runtime detection instead of metadata
|
||||
|
||||
@ -100,12 +100,10 @@ pub async fn qdrant_port(_token: APIToken) -> Json<ProvideQdrantInfo> {
|
||||
/// Starts the Qdrant server in a separate process.
|
||||
pub fn start_qdrant_server<R: tauri::Runtime>(app_handle: tauri::AppHandle<R>){
|
||||
let path = qdrant_base_path();
|
||||
if !path.exists() {
|
||||
if let Err(e) = fs::create_dir_all(&path){
|
||||
if !path.exists() && let Err(e) = fs::create_dir_all(&path){
|
||||
error!(Source="Qdrant"; "The required directory to host the Qdrant database could not be created: {}", e);
|
||||
set_qdrant_unavailable(format!("The Qdrant data directory could not be created: {e}"));
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
let (cert_path, key_path) = match create_temp_tls_files(&path) {
|
||||
|
||||
@ -50,7 +50,7 @@ pub fn kill_stale_process(pid_file_path: PathBuf, sidecar_type: SidecarType) ->
|
||||
|
||||
let killed = process.kill_with(Signal::Kill).unwrap_or_else(|| process.kill());
|
||||
if !killed {
|
||||
return Err(Error::new(ErrorKind::Other, "Failed to kill process"));
|
||||
return Err(Error::other("Failed to kill process"));
|
||||
}
|
||||
info!(Source="Stale Process Cleanup";"{}: Killed process: \"{}\"", sidecar_type,pid_file_path.display());
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user