chore(i18n): finish translating code comments and scripts to English
CI / Format and clippy (push) Successful in 1m57s
CI / Dependency audit (push) Successful in 13s
CI / Check desktop app (Linux) (push) Successful in 3m54s
CI / Tests (Linux) (push) Failing after 7m25s
Release / Create release (push) Successful in 6s
Release / CLI (linux-aarch64) (push) Successful in 1m48s
Release / CLI (linux-x86_64) (push) Successful in 2m39s
Release / Desktop app (linux-aarch64) (push) Successful in 10m9s
Release / Desktop app (linux-x86_64) (push) Successful in 12m20s
Release / Desktop app (windows) (push) Successful in 7m32s
Release / Build latest.json (push) Successful in 5s
CI / Format and clippy (push) Successful in 1m57s
CI / Dependency audit (push) Successful in 13s
CI / Check desktop app (Linux) (push) Successful in 3m54s
CI / Tests (Linux) (push) Failing after 7m25s
Release / Create release (push) Successful in 6s
Release / CLI (linux-aarch64) (push) Successful in 1m48s
Release / CLI (linux-x86_64) (push) Successful in 2m39s
Release / Desktop app (linux-aarch64) (push) Successful in 10m9s
Release / Desktop app (linux-x86_64) (push) Successful in 12m20s
Release / Desktop app (windows) (push) Successful in 7m32s
Release / Build latest.json (push) Successful in 5s
Completes the English-only standardization for code, comments, scripts and CI templates (UI/CLI-facing strings stay bilingual pt-BR/en, untouched). Covers the remaining crates/, apps/gui/ui/ and apps/gui/src-tauri/ comments, .gitea/ workflow and template comments, .githooks/ hooks, and the scripts/ source comments for the files already renamed in a prior commit (check.sh, generate-logo.py, install-hooks.sh). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VAyr8d7HuAdUGB6aA5xmDD
This commit is contained in:
1 parent
da212e6926
commit
6328220c60
129 files changed
+1961
-1834
No files matched your search
@@ -1,6 +1,6 @@
|
||||
//! Saúde do disco antes de varrer: lê o SMART (via `smartctl`, quando instalado) e
|
||||
//! os contadores de erro do kernel. Um disco com defeito deve ser copiado para uma
|
||||
//! imagem primeiro: cada leitura extra pode piorar o estado dele.
|
||||
//! Pre-scan disk health assessment: reads SMART data (via `smartctl`, when installed) and
|
||||
//! kernel I/O error counters. A failing drive should be imaged first, as every additional
|
||||
//! read pass can accelerate media degradation.
|
||||
|
||||
use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
@@ -8,43 +8,43 @@ use std::process::{Command, Stdio};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Default)]
|
||||
pub struct Health {
|
||||
/// Foi possível avaliar? (imagens de disco e dispositivos sem SMART ficam sem avaliação)
|
||||
/// Whether SMART assessment was possible (disk images and unsupported bridges return `false`).
|
||||
pub available: bool,
|
||||
/// "ok", "warning", "failing" ou "unknown".
|
||||
/// Overall status: `"ok"`, `"warning"`, `"failing"`, or `"unknown"`.
|
||||
pub status: String,
|
||||
pub summary: String,
|
||||
pub details: Vec<(String, String)>,
|
||||
pub advice: Vec<String>,
|
||||
/// Ficha do dispositivo, no estilo do CrystalDiskInfo (modelo, firmware, interface...).
|
||||
/// CrystalDiskInfo-style device summary (model, firmware, interface, etc.).
|
||||
pub info: Vec<(String, String)>,
|
||||
/// Saúde estimada em % (SSD: vida útil restante). `None` em HD, que não informa isso.
|
||||
/// Estimated health percentage (SSD remaining life). `None` for HDDs that do not report it.
|
||||
pub health_pct: Option<u8>,
|
||||
pub temperature_c: Option<i64>,
|
||||
pub power_on_hours: Option<i64>,
|
||||
pub power_cycles: Option<i64>,
|
||||
/// Total lido e gravado pelo computador, em bytes, quando o disco informa.
|
||||
/// Total host bytes read and written, when reported by the drive.
|
||||
pub host_reads: Option<u64>,
|
||||
pub host_writes: Option<u64>,
|
||||
/// Tabela completa de atributos SMART.
|
||||
/// Full table of SMART attributes.
|
||||
pub attributes: Vec<Attr>,
|
||||
/// Caminho avaliado de fato (o disco inteiro, quando `path` é uma partição).
|
||||
/// Actual device path queried (the containing whole disk when `path` is a partition).
|
||||
pub disk: String,
|
||||
/// Partição pedida, quando a avaliação foi feita no disco que a contém.
|
||||
/// Original partition path when the query was redirected to its parent disk.
|
||||
pub partition: Option<String>,
|
||||
}
|
||||
|
||||
/// Uma linha da tabela de atributos SMART.
|
||||
/// A single row in the SMART attribute table.
|
||||
#[derive(Debug, Clone, Serialize, Default)]
|
||||
pub struct Attr {
|
||||
/// Identificador em hexadecimal, como o CrystalDiskInfo mostra ("05", "C5").
|
||||
/// Two-digit hex attribute ID as displayed by CrystalDiskInfo (`"05"`, `"C5"`).
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
/// Valores normalizados (ATA): atual, pior já visto e limite de falha.
|
||||
/// Normalized ATA values: current, worst, and failure threshold.
|
||||
pub value: Option<i64>,
|
||||
pub worst: Option<i64>,
|
||||
pub thresh: Option<i64>,
|
||||
pub raw: String,
|
||||
/// "ok", "warning" ou "failing".
|
||||
/// Attribute status: `"ok"`, `"warning"`, or `"failing"`.
|
||||
pub status: String,
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ impl Health {
|
||||
|
||||
const IMAGE_ADVICE: &str = "Crie a imagem do disco primeiro (botão \"Criar imagem\" ou `guara image`) e varra a cópia. Cada leitura extra pode piorar um disco com defeito.";
|
||||
|
||||
/// Avalia o dispositivo `path`. Para arquivos comuns (imagens) devolve "sem avaliação".
|
||||
/// Evaluates disk health for `path`. Regular image files return an unassessed report.
|
||||
pub fn check(path: &str) -> Health {
|
||||
#[cfg(unix)]
|
||||
let is_dev = {
|
||||
@@ -88,8 +88,8 @@ pub fn check(path: &str) -> Health {
|
||||
h
|
||||
}
|
||||
|
||||
/// O SMART é do disco, não da partição: `/dev/sda1` vira `/dev/sda`,
|
||||
/// `/dev/nvme0n1p2` vira `/dev/nvme0n1` e `/dev/disk2s1` vira `/dev/disk2`.
|
||||
/// SMART belongs to the physical disk rather than a partition: `/dev/sda1` -> `/dev/sda`,
|
||||
/// `/dev/nvme0n1p2` -> `/dev/nvme0n1`, and `/dev/disk2s1` -> `/dev/disk2`.
|
||||
pub fn parent_disk(path: &str) -> String {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
@@ -117,7 +117,7 @@ pub fn parent_disk(path: &str) -> String {
|
||||
}
|
||||
|
||||
fn smartctl_name(path: &str) -> String {
|
||||
// Windows: \\.\PhysicalDriveN -> /dev/sdX (convenção do smartctl)
|
||||
// Windows: \\.\PhysicalDriveN -> /dev/sdX (smartctl device naming convention)
|
||||
if let Some(n) = path
|
||||
.strip_prefix(r"\\.\PhysicalDrive")
|
||||
.and_then(|n| n.parse::<u8>().ok())
|
||||
@@ -139,9 +139,9 @@ fn run_smartctl(path: &str) -> Option<Value> {
|
||||
.stderr(Stdio::null())
|
||||
.output()
|
||||
.ok()?;
|
||||
// smartctl usa bits do código de saída para avisos; o JSON vale mesmo assim
|
||||
// smartctl encodes warnings in exit status bits; the JSON output is still valid
|
||||
let v: Value = serde_json::from_slice(&out.stdout).ok()?;
|
||||
// sem permissão ou dispositivo não suportado
|
||||
// insufficient permissions or unsupported device
|
||||
if v.pointer("/smartctl/messages")
|
||||
.and_then(|m| m.as_array())
|
||||
.is_some_and(|m| m.iter().any(|x| x["severity"] == "error"))
|
||||
@@ -163,14 +163,14 @@ fn attr(v: &Value, id: u64) -> Option<i64> {
|
||||
.as_i64()
|
||||
}
|
||||
|
||||
/// Interpreta a saída JSON do `smartctl` (testável sem disco).
|
||||
/// Parses `smartctl -j` JSON output (unit-testable without hardware).
|
||||
pub fn parse_smartctl(v: &Value) -> Health {
|
||||
let mut h = Health {
|
||||
available: true,
|
||||
status: "ok".into(),
|
||||
..Default::default()
|
||||
};
|
||||
let mut bad = 0u32; // 2 = falhando, 1 = atenção
|
||||
let mut bad = 0u32; // 2 = failing, 1 = warning
|
||||
let mut note = |h: &mut Health, sev: u32, k: &str, val: String| {
|
||||
bad = bad.max(sev);
|
||||
h.details.push((k.to_string(), val));
|
||||
@@ -204,7 +204,7 @@ pub fn parse_smartctl(v: &Value) -> Health {
|
||||
h.details
|
||||
.push(("Autoavaliação SMART".into(), "aprovado".into()));
|
||||
}
|
||||
// ATA (HD e SSD SATA)
|
||||
// ATA (SATA HDDs and SSDs)
|
||||
if let Some(n) = attr(v, 5) {
|
||||
if n > 0 {
|
||||
note(
|
||||
@@ -320,7 +320,7 @@ fn n(v: &Value, p: &str) -> Option<i64> {
|
||||
v.pointer(p).and_then(|x| x.as_i64())
|
||||
}
|
||||
|
||||
/// Ficha do dispositivo e métricas gerais (temperatura, horas, total lido/gravado, saúde %).
|
||||
/// Extracts device identity and summary metrics (temperature, power-on hours, host R/W, health %).
|
||||
fn fill_info(v: &Value, h: &mut Health) {
|
||||
let mut put = |k: &str, val: Option<String>| {
|
||||
if let Some(val) = val {
|
||||
@@ -395,7 +395,7 @@ fn fill_info(v: &Value, h: &mut Health) {
|
||||
h.power_on_hours = n(v, "/power_on_time/hours");
|
||||
h.power_cycles = n(v, "/power_cycle_count");
|
||||
if let Some(l) = v.get("nvme_smart_health_information_log") {
|
||||
// a unidade NVMe vale 1000 setores de 512 bytes
|
||||
// 1 NVMe data unit = 1,000 x 512-byte sectors
|
||||
h.host_reads = l["data_units_read"].as_u64().map(|u| u * 512_000);
|
||||
h.host_writes = l["data_units_written"].as_u64().map(|u| u * 512_000);
|
||||
h.health_pct = l["percentage_used"]
|
||||
@@ -406,7 +406,7 @@ fn fill_info(v: &Value, h: &mut Health) {
|
||||
let lba = n(v, "/logical_block_size").unwrap_or(512) as u64;
|
||||
h.host_reads = attr(v, 242).map(|x| x as u64 * lba);
|
||||
h.host_writes = attr(v, 241).map(|x| x as u64 * lba);
|
||||
// SSD SATA: vida útil restante no valor normalizado de um destes atributos
|
||||
// SATA SSD: remaining life percentage stored in the normalized value of one of these attributes
|
||||
// (231 SSD Life Left, 233 Media Wearout, 177 Wear Leveling, 202 Percent Lifetime Remain)
|
||||
h.health_pct = [231u64, 233, 177, 202, 169]
|
||||
.iter()
|
||||
@@ -416,7 +416,7 @@ fn fill_info(v: &Value, h: &mut Health) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Capacidade como o fabricante anuncia (base 1000): "500,1 GB".
|
||||
/// Formats drive capacity in decimal manufacturer units (base 1000, e.g. `"500,1 GB"`).
|
||||
fn decimal_size(b: u64) -> String {
|
||||
let units = ["B", "kB", "MB", "GB", "TB", "PB"];
|
||||
let mut x = b as f64;
|
||||
@@ -437,7 +437,7 @@ fn attr_field(v: &Value, id: u64, f: &str) -> Option<i64> {
|
||||
.as_i64()
|
||||
}
|
||||
|
||||
/// Atributos cujo valor bruto acima de zero já é motivo de atenção.
|
||||
/// Critical ATA attributes where any non-zero raw count warrants a warning.
|
||||
const RAW_WARN: [u64; 5] = [5, 196, 197, 198, 187];
|
||||
|
||||
fn fill_attributes(v: &Value, h: &mut Health) {
|
||||
@@ -484,7 +484,7 @@ fn fill_attributes(v: &Value, h: &mut Health) {
|
||||
}
|
||||
}
|
||||
if let Some(l) = v.get("nvme_smart_health_information_log") {
|
||||
// mesma ordem e nomes que o CrystalDiskInfo usa para NVMe
|
||||
// same order and labels used by CrystalDiskInfo for NVMe health logs
|
||||
let rows: [(u8, &str, &str); 15] = [
|
||||
(1, "Critical Warning", "critical_warning"),
|
||||
(2, "Composite Temperature", "temperature"),
|
||||
@@ -529,7 +529,7 @@ fn fill_attributes(v: &Value, h: &mut Health) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Contadores de erro de E/S do kernel (Linux): reforçam o aviso do SMART.
|
||||
/// Linux kernel sysfs I/O error counters: supplement SMART warnings.
|
||||
fn kernel_errors(path: &str, h: &mut Health) {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user