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

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:
Lucas RayanandClaude Sonnet 5 committed 2026-10-30 20:43:02 -03:00
1 parent da212e6926
commit 6328220c60
129 files changed
+1961 -1834

No files matched your search

+52 -52
View File
@@ -1,10 +1,10 @@
//! Imagens de disco virtual: QCOW2, VMDK, VHD, VHDX e DMG.
//! Virtual disk image tests: QCOW2, VMDK, VHD, VHDX, and DMG.
//!
//! Os arquivos de `tests/fixtures/vdisk` foram feitos por ferramentas reais (VirtualBox para
//! VMDK/VHD, qemu para QCOW2, hdiutil para DMG) e conferidos contra o conteúdo bruto. VHDX, DMG
//! sintético e discos diferenciais são montados aqui, byte a byte, a partir da especificação.
//! As imagens do dfvfs em target/testdata (scripts/fetch-testdata.sh) são conferidas por hash,
//! calculado com um leitor independente (7-Zip), e pulam quando ausentes.
//! Fixtures in `tests/fixtures/vdisk` were created by real tools (`VBoxManage` for VMDK/VHD,
//! `qemu-img` for QCOW2, `hdiutil` for DMG) and verified against the raw disk image. VHDX,
//! synthetic DMG chunks, and differencing chains are constructed byte-for-byte from the specs.
//! External `dfvfs` images in `target/testdata` (`scripts/fetch-testdata.sh`) are verified by
//! SHA-256 against independent `7z` extractions and skipped when absent.
use guara_core::source::{open_path, read_vec, Source};
use sha2::{Digest, Sha256};
@@ -39,7 +39,7 @@ fn sha(src: &dyn Source) -> String {
h.finalize().iter().map(|b| format!("{b:02x}")).collect()
}
/// Lê o disco inteiro e também em pedaços que cruzam blocos, comparando com `want`.
/// Verifies both full-disk reads and unaligned cross-block reads against `want`.
fn check_content(path: &Path, want: &[u8]) {
let s = open_path(path).unwrap_or_else(|e| panic!("{}: {e}", path.display()));
assert_eq!(s.size(), want.len() as u64, "{}", path.display());
@@ -63,19 +63,19 @@ fn check_content(path: &Path, want: &[u8]) {
path.display()
);
}
// leitura além do fim devolve só o que existe
// reads extending past EOF return only the remaining bytes
let mut buf = [0u8; 64];
assert_eq!(s.read_at(want.len() as u64 - 10, &mut buf).unwrap(), 10);
assert_eq!(s.read_at(want.len() as u64, &mut buf).unwrap(), 0);
}
// ---------- imagens feitas por ferramentas reais ----------
// ---------- fixtures created by real tools ----------
#[test]
fn virtualbox_vmdk_sparse_and_stream_optimized() {
let want = raw();
check_content(&fx("disk.vmdk"), &want);
// streamOptimized: grãos comprimidos com zlib e cabeçalho no rodapé
// `streamOptimized` VMDK: deflate-compressed grains and footer descriptor
check_content(&fx("disk-stream.vmdk"), &want);
}
@@ -92,7 +92,7 @@ fn qemu_qcow2_and_hdiutil_dmg_match_a_reference_reader() {
sha(s.as_ref()),
"a6c2f0e39afe6c6ab432ca5465349fcefe8dc944398e97b2d957d3f89dbb5d80"
);
// UDIF com chunks zlib, zerados e ignorados
// UDIF DMG with zlib, zero-fill, and ignored chunks
let d = open_path(&fx("hfsplus_zlib.dmg")).unwrap();
assert_eq!(d.size(), 1_954_304);
assert_eq!(
@@ -101,7 +101,7 @@ fn qemu_qcow2_and_hdiutil_dmg_match_a_reference_reader() {
);
}
// ---------- montagem de imagens sintéticas ----------
// ---------- synthetic image builders ----------
fn be(v: &mut [u8], o: usize, x: u64, n: usize) {
v[o..o + n].copy_from_slice(&x.to_be_bytes()[8 - n..]);
@@ -122,7 +122,7 @@ fn zlib(data: &[u8]) -> Vec<u8> {
e.finish().unwrap()
}
/// QCOW2 v3 com clusters de 64 KiB: zerados (sem entrada e com a flag), brutos e comprimidos.
/// Builds a QCOW2 v3 image (64 KiB clusters) with unallocated, zero-flagged, raw, and compressed clusters.
fn build_qcow2(data: &[u8]) -> Vec<u8> {
const CS: usize = 1 << 16;
let clusters = data.len() / CS;
@@ -134,14 +134,14 @@ fn build_qcow2(data: &[u8]) -> Vec<u8> {
be(&mut img, 36, 1, 4);
be(&mut img, 40, CS as u64, 8);
be(&mut img, 100, 112, 4);
be(&mut img, CS, (2 * CS as u64) | (1 << 63), 8); // L1 -> L2 no cluster 2
be(&mut img, CS, (2 * CS as u64) | (1 << 63), 8); // L1 entry pointing to L2 table at cluster 2
for i in 0..clusters {
let c = &data[i * CS..(i + 1) * CS];
let entry: u64 = if c.iter().all(|&b| b == 0) {
if i % 2 == 0 {
0
} else {
1 // zerado explícito
1 // explicit zero-cluster flag (bit 0)
}
} else if i % 3 == 0 {
let z = deflate(c);
@@ -196,7 +196,7 @@ fn base64(d: &[u8]) -> String {
s
}
/// ADC só com literais e cópias de 3 bytes (deslocamento 8), como o `hdiutil` produz.
/// Encodes payload using ADC literal runs and 3-byte backreferences (offset 8).
fn adc_pattern(len: usize) -> (Vec<u8>, Vec<u8>) {
let pat = *b"ADC-test";
let mut enc = vec![0x80 | 7];
@@ -211,7 +211,7 @@ fn adc_pattern(len: usize) -> (Vec<u8>, Vec<u8>) {
if n >= 4 {
enc.extend_from_slice(&[0x40 | (n as u8 - 4), 0, 7]);
} else {
enc.extend_from_slice(&[((n as u8 - 3) << 2), 7]); // 2 bytes, comprimento 3
enc.extend_from_slice(&[((n as u8 - 3) << 2), 7]); // 2-byte match opcode, length 3
}
made += n;
}
@@ -301,7 +301,7 @@ fn qcow2_with_encryption_or_a_remote_backing_file_is_refused() {
assert!(e.contains("não é um arquivo local"), "{e}");
}
/// Filho QCOW2 que só aloca o cluster 1 (dados), marca o 2 como zerado e deixa o resto para o pai.
/// Builds a child QCOW2 that allocates cluster 1, zero-flags cluster 2, and leaves the rest to `backing`.
fn build_qcow2_child(backing: &str, fmt: Option<&str>, own: &[u8]) -> Vec<u8> {
const CS: usize = 1 << 16;
let mut img = vec![0u8; 3 * CS];
@@ -316,7 +316,7 @@ fn build_qcow2_child(backing: &str, fmt: Option<&str>, own: &[u8]) -> Vec<u8> {
be(&mut img, 40, CS as u64, 8);
be(&mut img, 100, 112, 4);
if let Some(f) = fmt {
// extensão 0xE2792ACA com o nome do formato do apoio, depois o fim das extensões
// header extension `0xE2792ACA` (backing file format name) followed by end-of-extensions (`0`)
be(&mut img, 112, 0xE279_2ACA, 4);
be(&mut img, 116, f.len() as u64, 4);
img[120..120 + f.len()].copy_from_slice(f.as_bytes());
@@ -326,7 +326,7 @@ fn build_qcow2_child(backing: &str, fmt: Option<&str>, own: &[u8]) -> Vec<u8> {
img.extend_from_slice(own);
img.resize(img.len().div_ceil(CS) * CS, 0);
be(&mut img, 2 * CS + 8, host | (1 << 63), 8); // cluster 1
be(&mut img, 2 * CS + 16, 1, 8); // cluster 2: zerado de propósito
be(&mut img, 2 * CS + 16, 1, 8); // cluster 2: explicitly zeroed (must not fall back to parent)
img
}
@@ -345,12 +345,12 @@ fn qcow2_backing_file_supplies_what_the_child_did_not_allocate() {
std::fs::write(&p, build_qcow2_child("base.raw", fmt, &own)).unwrap();
check_content(&p, &expect);
}
// com o pai em outro formato: o filho aponta para um QCOW2
// multi-hop backing chain: QCOW2 child -> QCOW2 parent -> raw base
std::fs::write(dir.path().join("base.qcow2"), build_qcow2(&base)).unwrap();
let p = dir.path().join("c.qcow2");
std::fs::write(&p, build_qcow2_child("base.qcow2", Some("qcow2"), &own)).unwrap();
check_content(&p, &expect);
// sem o pai, a abertura diz o que falta
// missing backing file produces a clear error naming the missing parent
std::fs::remove_file(dir.path().join("base.raw")).unwrap();
let e = open_path(&dir.path().join("a.qcow2"))
.err()
@@ -384,10 +384,10 @@ fn vmdk_descriptor_with_flat_and_zero_extents() {
check_content(&p, &expect);
}
/// VMDK esparso feito à mão: 16 grãos de 64 KiB; `grains[i]` = `None` (não alocado, vem do pai),
/// `Some(None)` (zerado de propósito) ou `Some(Some(dados))`.
/// Builds a sparse VMDK with sixteen 64 KiB grains: `None` = unallocated (falls back to parent),
/// `Some(None)` = zeroed grain (`GTE == 1`), or `Some(Some(data))` = allocated grain.
fn build_vmdk_sparse(descriptor: &str, grains: &[Option<Option<Vec<u8>>>]) -> Vec<u8> {
const GRAIN: usize = 128; // setores
const GRAIN: usize = 128; // capacity in 512-byte sectors
let mut img = vec![0u8; 26 * 512];
img[..4].copy_from_slice(b"KDMV");
le(&mut img, 4, 1, 4);
@@ -400,7 +400,7 @@ fn build_vmdk_sparse(descriptor: &str, grains: &[Option<Option<Vec<u8>>>]) -> Ve
le(&mut img, 56, 21, 8);
le(&mut img, 64, 26, 8);
img[512..512 + descriptor.len()].copy_from_slice(descriptor.as_bytes());
le(&mut img, 21 * 512, 22, 4); // diretório de grãos -> tabela no setor 22
le(&mut img, 21 * 512, 22, 4); // grain directory entry pointing to the grain table at sector 22
for (i, g) in grains.iter().enumerate() {
let entry = match g {
None => 0,
@@ -432,7 +432,7 @@ fn vmdk_child_reads_the_parent_for_unallocated_grains() {
let own = vec![0x37u8; 65536];
let mut grains: Vec<Option<Option<Vec<u8>>>> = vec![None; 16];
grains[3] = Some(Some(own.clone()));
grains[5] = Some(None); // zerado de propósito: não consulta o pai
grains[5] = Some(None); // explicitly zeroed grain (`GTE == 1`): does not fall back to parent
let child = build_vmdk_sparse(
"# Disk DescriptorFile\nversion=1\nCID=22222222\nparentCID=11111111\ncreateType=\"monolithicSparse\"\nparentFileNameHint=\"base.vmdk\"\n",
&grains,
@@ -445,17 +445,17 @@ fn vmdk_child_reads_the_parent_for_unallocated_grains() {
check_content(&p, &expect);
}
/// Snapshot real do VirtualBox: o filho só diz o UUID do pai (`ddb.uuid.parent`), sem nome.
/// VirtualBox snapshot VMDK where the child references its parent solely via `ddb.uuid.parent`.
#[test]
fn virtualbox_snapshot_vmdk_finds_its_parent_by_uuid() {
let dir = tempfile::tempdir().unwrap();
let sub = dir.path().join("Snapshots");
std::fs::create_dir(&sub).unwrap();
// o pai fica na pasta de cima, como o VirtualBox organiza a máquina
// parent VMDK sits in the parent directory, matching VirtualBox's `Snapshots/` layout
std::fs::copy(fx("disk.vmdk"), dir.path().join("disco-base.vmdk")).unwrap();
std::fs::copy(fx("vbox-snapshot.vmdk"), sub.join("filho.vmdk")).unwrap();
check_content(&sub.join("filho.vmdk"), &raw());
// sem o pai por perto, a abertura explica
// when no VMDK with the parent UUID exists nearby, opening returns a descriptive error
std::fs::remove_file(dir.path().join("disco-base.vmdk")).unwrap();
let e = open_path(&sub.join("filho.vmdk"))
.err()
@@ -516,7 +516,7 @@ fn vhd_fixed_hides_the_footer() {
check_content(&p, &want);
}
/// VHD diferencial: a filha só traz o setor 100 e o bloco inteiro do fim; o resto vem do pai.
/// Builds a differencing VHD where only sector 100 of block 0 and all of block 1 are present in the child.
#[test]
fn vhd_differencing_reads_the_parent_for_missing_sectors() {
let want = raw();
@@ -525,7 +525,7 @@ fn vhd_differencing_reads_the_parent_for_missing_sectors() {
parent.extend_from_slice(&vhd_footer(want.len() as u64, 2, u64::MAX));
std::fs::write(dir.path().join("pai.vhd"), &parent).unwrap();
const BLOCK: usize = 1 << 20; // um bloco só
const BLOCK: usize = 1 << 20; // single 2 MiB block
let mut f = vec![0u8; 512 + 1024 + 512];
let hdr = vhd_footer(want.len() as u64, 4, 512);
f[..512].copy_from_slice(&hdr);
@@ -541,9 +541,9 @@ fn vhd_differencing_reads_the_parent_for_missing_sectors() {
.collect::<Vec<u8>>();
dh[64..64 + name.len()].copy_from_slice(&name);
f[512..1536].copy_from_slice(&dh);
be(&mut f, 1536, 4, 4); // bloco 0 no setor 4
be(&mut f, 1536, 4, 4); // block 0 starts at sector 4
f.resize(4 * 512, 0);
// bitmap (4096 setores = 512 bytes) com o setor 100 presente, depois os dados
// 512-byte sector bitmap (4096 sectors) with only sector 100 marked present, followed by data
let mut bitmap = vec![0u8; 512];
bitmap[100 / 8] |= 0x80 >> (100 % 8);
f.extend_from_slice(&bitmap);
@@ -559,7 +559,7 @@ fn vhd_differencing_reads_the_parent_for_missing_sectors() {
expect[100 * 512..101 * 512].copy_from_slice(&marker);
check_content(&p, &expect);
// sem o pai a abertura falha com o motivo
// missing parent VHD returns a descriptive error
std::fs::remove_file(dir.path().join("pai.vhd")).unwrap();
let e = open_path(&p).err().expect("deveria recusar").to_string();
assert!(e.contains("disco pai não encontrado"), "{e}");
@@ -584,8 +584,8 @@ fn guid(s: &str) -> [u8; 16] {
const MB: usize = 1 << 20;
/// VHDX com blocos de 1 MiB. `blocks[i]`: `None` = não presente, `Some((estado, dados))`.
/// Com `parent`, acrescenta o localizador de pai e o bitmap de setores (`bitmap`).
/// Builds a VHDX image with 1 MiB blocks (`None` = not present, `Some((state, data))`).
/// When `parent` is provided, writes a VHDX parent locator and sector bitmap block.
fn build_vhdx(
size: u64,
blocks: &[Option<(u64, Vec<u8>)>],
@@ -596,7 +596,7 @@ fn build_vhdx(
img[..8].copy_from_slice(b"vhdxfile");
img[64 * 1024..64 * 1024 + 4].copy_from_slice(b"head");
img[128 * 1024..128 * 1024 + 4].copy_from_slice(b"head");
// tabela de regiões: BAT em 2 MiB, metadados em 1 MiB
// region table: BAT at 2 MiB, metadata region at 1 MiB
let rt = 192 * 1024;
img[rt..rt + 4].copy_from_slice(b"regi");
le(&mut img, rt + 8, 2, 4);
@@ -606,7 +606,7 @@ fn build_vhdx(
img[rt + 48..rt + 64].copy_from_slice(&guid("8B7CA206-4790-4B9A-B8FE-575F050F886E"));
le(&mut img, rt + 64, MB as u64, 8);
le(&mut img, rt + 72, MB as u64, 4);
// metadados
// metadata region items
let m = MB;
img[m..m + 8].copy_from_slice(b"metadata");
let mut items: Vec<([u8; 16], Vec<u8>)> = vec![];
@@ -650,7 +650,7 @@ fn build_vhdx(
img[m + at..m + at + data.len()].copy_from_slice(data);
at += data.len().div_ceil(8) * 8;
}
// blocos de dados a partir de 4 MiB; o BAT guarda estado e deslocamento (em MiB)
// payload blocks start at 4 MiB; BAT entries encode state in low 3 bits and file offset
let ratio = (1usize << 23) * 512 / MB;
let bat = 2 * MB;
for (i, b) in blocks.iter().enumerate() {
@@ -681,7 +681,7 @@ fn build_vhdx(
#[test]
fn vhdx_dynamic_with_zero_and_missing_blocks() {
let want = raw(); // 1 MiB = um bloco
let want = raw(); // 1 MiB = single payload block
let mut expect = want.clone();
expect.extend_from_slice(&vec![0u8; 3 * MB]);
let tail = vec![0x5Au8; 100_000];
@@ -690,8 +690,8 @@ fn vhdx_dynamic_with_zero_and_missing_blocks() {
4 * MB as u64,
&[
Some((6, want.clone())),
Some((2, vec![])), // zerado
None, // não presente
Some((2, vec![])), // `PAYLOAD_BLOCK_ZERO`
None, // `PAYLOAD_BLOCK_NOT_PRESENT`
Some((6, tail)),
],
None,
@@ -708,7 +708,7 @@ fn vhdx_differencing_uses_the_sector_bitmap() {
let want = raw();
let dir = tempfile::tempdir().unwrap();
std::fs::write(dir.path().join("pai.raw"), &want).unwrap();
// filho: bloco 0 parcialmente presente, só com os setores 3 e 2000..2010 no filho
// differencing child: block 0 is `PAYLOAD_BLOCK_PARTIALLY_PRESENT` with sectors 3 and 2000..2010 in child
let mut data = vec![0u8; MB];
let mut bm = vec![0u8; 512];
let mut expect = want.clone();
@@ -729,7 +729,7 @@ fn vhdx_differencing_uses_the_sector_bitmap() {
fn dmg_with_every_chunk_type() {
let want = raw();
let sec = 512usize;
// 8 chunks de 128 setores (64 KiB)
// 8 chunks of 128 sectors (64 KiB each)
let part = |i: usize| want[i * 128 * sec..(i + 1) * 128 * sec].to_vec();
let (adc_enc, adc_want) = adc_pattern(128 * sec);
let mut bz = bzip2::write::BzEncoder::new(vec![], bzip2::Compression::default());
@@ -739,12 +739,12 @@ fn dmg_with_every_chunk_type() {
ty: 1,
sectors: 128,
payload: part(0),
}, // bruto
}, // raw uncompressed chunk (`0x00000001`)
DmgChunk {
ty: 0,
sectors: 128,
payload: vec![],
}, // zerado
}, // `PAYLOAD_BLOCK_ZERO`
DmgChunk {
ty: 0x8000_0005,
sectors: 128,
@@ -764,7 +764,7 @@ fn dmg_with_every_chunk_type() {
ty: 2,
sectors: 128,
payload: vec![],
}, // ignorado
}, // ignored/comment chunk
DmgChunk {
ty: 0x8000_0005,
sectors: 128,
@@ -785,8 +785,8 @@ fn dmg_with_every_chunk_type() {
check_content(&p, &expect);
}
/// Chunks `ULFO` com dados compactados pelo compressor de referência da Apple (`lzfse`):
/// um bloco `bvx2` (FSE, 64 KiB) e um pequeno (`bvxn`/LZVN).
/// DMG with `ULFO` (LZFSE) chunks compressed by Apple's reference `lzfse` implementation:
/// one 64 KiB `bvx2` (FSE) block and one small `bvxn` (LZVN) block.
#[test]
fn dmg_lzfse_chunks_from_the_reference_compressor() {
let big = std::fs::read(fx("lzfse-64k.bin")).unwrap();
@@ -835,11 +835,11 @@ fn dmg_with_a_corrupt_lzfse_chunk_and_encrypted_are_refused_with_a_reason() {
assert!(e.contains("cifrado"), "{e}");
}
// ---------- imagens reais do dfvfs (target/testdata) ----------
// ---------- external `dfvfs` reference images (`target/testdata`) ----------
#[test]
fn dfvfs_images_match_a_reference_reader() {
// hashes do disco virtual inteiro, conferidos com o 7-Zip (árvore de arquivos e partições)
// full virtual disk SHA-256 digests cross-checked against `7z` extraction
let table: &[(&str, &str)] = &[
(
"ext2.vhdx",