From 5e0268d40e72a85e4cee28333df6ccd4fd5bc8a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 16 Jan 2024 15:43:03 +0100 Subject: [PATCH] Fix the sysinfo errors --- meilisearch/src/analytics/segment_analytics.rs | 11 ++++++----- meilisearch/src/option.rs | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/meilisearch/src/analytics/segment_analytics.rs b/meilisearch/src/analytics/segment_analytics.rs index 86a5eddb9..6969c9b3d 100644 --- a/meilisearch/src/analytics/segment_analytics.rs +++ b/meilisearch/src/analytics/segment_analytics.rs @@ -18,7 +18,7 @@ use segment::message::{Identify, Track, User}; use segment::{AutoBatcher, Batcher, HttpClient}; use serde::Serialize; use serde_json::{json, Value}; -use sysinfo::{DiskExt, System, SystemExt}; +use sysinfo::{Disks, System}; use time::OffsetDateTime; use tokio::select; use tokio::sync::mpsc::{self, Receiver, Sender}; @@ -386,16 +386,17 @@ impl Segment { fn compute_traits(opt: &Opt, stats: Stats) -> Value { static FIRST_START_TIMESTAMP: Lazy = Lazy::new(Instant::now); static SYSTEM: Lazy = Lazy::new(|| { + let disks = Disks::new_with_refreshed_list(); let mut sys = System::new_all(); sys.refresh_all(); - let kernel_version = - sys.kernel_version().and_then(|k| k.split_once('-').map(|(k, _)| k.to_string())); + let kernel_version = System::kernel_version() + .and_then(|k| k.split_once('-').map(|(k, _)| k.to_string())); json!({ - "distribution": sys.name(), + "distribution": System::name(), "kernel_version": kernel_version, "cores": sys.cpus().len(), "ram_size": sys.total_memory(), - "disk_size": sys.disks().iter().map(|disk| disk.total_space()).max(), + "disk_size": disks.iter().map(|disk| disk.total_space()).max(), "server_provider": std::env::var("MEILI_SERVER_PROVIDER").ok(), }) }); diff --git a/meilisearch/src/option.rs b/meilisearch/src/option.rs index a0672c9cf..befb96294 100644 --- a/meilisearch/src/option.rs +++ b/meilisearch/src/option.rs @@ -20,7 +20,7 @@ use rustls::server::{ use rustls::RootCertStore; use rustls_pemfile::{certs, pkcs8_private_keys, rsa_private_keys}; use serde::{Deserialize, Serialize}; -use sysinfo::{RefreshKind, System, SystemExt}; +use sysinfo::{RefreshKind, System}; use url::Url; const POSSIBLE_ENV: [&str; 2] = ["development", "production"];