fix windows process check
This commit is contained in:
parent
c259c39807
commit
6c07a835b0
3 changed files with 19 additions and 2 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#[cfg(debug_assertions)]
|
||||
use crate::store::Core;
|
||||
use tracing_subscriber::prelude::*;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
|
|
|
|||
|
|
@ -545,6 +545,7 @@ async fn wait_for_exit(
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn process_exists_os(pid: u32) -> bool {
|
||||
// SAFETY: `kill` with signal 0 performs existence/permission checks only and
|
||||
// does not deliver a signal.
|
||||
|
|
@ -558,3 +559,18 @@ fn process_exists_os(pid: u32) -> bool {
|
|||
.unwrap_or_default();
|
||||
err == libc::EPERM
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn process_exists_os(pid: u32) -> bool {
|
||||
let pid = sysinfo::Pid::from_u32(pid);
|
||||
let mut system = sysinfo::System::new();
|
||||
|
||||
system.refresh_processes(sysinfo::ProcessesToUpdate::Some(&[pid]), true);
|
||||
system.process(pid).is_some()
|
||||
}
|
||||
|
||||
#[cfg(not(any(unix, windows)))]
|
||||
fn process_exists_os(pid: u32) -> bool {
|
||||
let _ = pid;
|
||||
false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ fn get_ratelimit_reset(headers: &reqwest::header::HeaderMap) -> Option<u64> {
|
|||
pub async fn send_request(request: reqwest::Request) -> LauncherResult<reqwest::Response> {
|
||||
if let Some(host) = request.url().host_str() {
|
||||
if host == "api.modrinth.com" {
|
||||
let start = std::time::Instant::now();
|
||||
let _start = std::time::Instant::now();
|
||||
MODRINTH_RATE_LIMITER.until_ready().await;
|
||||
}
|
||||
}
|
||||
|
|
@ -151,7 +151,7 @@ pub async fn fetch_advanced(
|
|||
if let Ok(parsed_url) = reqwest::Url::parse(url) {
|
||||
if let Some(host) = parsed_url.host_str() {
|
||||
if host == "api.modrinth.com" {
|
||||
let start = std::time::Instant::now();
|
||||
let _start = std::time::Instant::now();
|
||||
MODRINTH_RATE_LIMITER.until_ready().await;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue