8 Commits
Author SHA1 Message Date
Lucas RayanandClaude Sonnet 5.5 0b9a16e8a0 feat: responsive pause/stop, non-blocking update with progress bar, delete saved sessions (1.5.0)
Release / Create release (push) Successful in 13s
CI / Format and clippy (push) Successful in 25s
CI / Dependency audit (push) Successful in 11s
Release / CLI (linux-x86_64) (push) Successful in 2m31s
CI / Tests (Linux) (push) Successful in 4m28s
CI / Check desktop app (Linux) (push) Successful in 1m35s
Release / CLI (linux-aarch64) (push) Successful in 1m46s
Release / Desktop app (linux-x86_64) (push) Successful in 6m9s
Release / Desktop app (windows) (push) Successful in 4m13s
Release / Desktop app (linux-aarch64) (push) Successful in 9m51s
- carve: check cancellation inside chunks and per hit; reassembly stage is cancellable
- status exposes `stopping`; UI shows "Pausing…" immediately
- Tauri update commands run off the UI thread; download percentage reported
- delete autosaved sessions manually (one/all) and by retention setting
- chore(release): 1.5.0

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 16:36:34 -03:00
lucasrguerra db5b972650 Merge pull request 'Browse and recover by folder (1.4.0)' (#1) from feat/navegacao-pastas into main
Release / Desktop app (linux-x86_64) (push) Successful in 5m54s
Release / Desktop app (windows) (push) Successful in 4m19s
Release / Desktop app (linux-aarch64) (push) Successful in 12m4s
CI / Format and clippy (push) Successful in 30s
CI / Tests (Linux) (push) Successful in 4m42s
Release / Create release (push) Successful in 8s
CI / Dependency audit (push) Successful in 15s
CI / Check desktop app (Linux) (push) Successful in 1m24s
Release / CLI (linux-x86_64) (push) Successful in 2m2s
Release / CLI (linux-aarch64) (push) Successful in 1m55s
2026-11-03 17:10:45 +00:00
Lucas RayanandClaude Opus 5.5 c5f21f749d docs: folder browsing screenshots and docs; translate folder counts
CI / Format and clippy (pull_request) Successful in 31s
CI / Dependency audit (pull_request) Successful in 22s
CI / Check desktop app (Linux) (pull_request) Successful in 1m12s
CI / Tests (Linux) (pull_request) Successful in 4m59s
Retakes the explorer screenshots on 1.4.0 (they still showed 0.4.0) and adds
the Folders view in English and Portuguese. The folder rows' file count sat
inside .xp-lnm, which the DOM translator skips, so it stayed in Portuguese
in the English UI; it is now translated explicitly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 13:59:05 -03:00
Lucas RayanandClaude Opus 5.5 bf93ca01b4 chore(release): 1.4.0
CI / Format and clippy (pull_request) Successful in 2m25s
CI / Dependency audit (pull_request) Successful in 11s
CI / Check desktop app (Linux) (pull_request) Successful in 1m22s
CI / Tests (Linux) (pull_request) Successful in 8m45s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 13:39:16 -03:00
Lucas RayanandClaude Opus 5.5 00aceecf70 feat(ui): browse and recover by folder
A Folders mode next to grid and list shows one level at a time: subfolders
first with their file count and size, then the files, under a clickable
breadcrumb. Folders and files are marked with tri-state boxes that persist
while navigating; the bar shows the exact total from the core, and the
selection is recovered relative to each marked folder. The sidebar folder
tree navigates in this mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 13:38:33 -03:00
Lucas RayanandClaude Opus 5.5 ca677a8bc1 feat(recover): recover a selection of folders relative to each marked folder
A marked folder a/b/Projeto is recreated as Projeto/... with everything
inside it; single marked files go to the destination root and unmarked
files inside a marked folder are left out. recover_start accepts
{selection: {folders, ids, exclude}}.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 13:31:45 -03:00
Lucas RayanandClaude Opus 5.5 b274f0b7ef feat(explorer): list one folder level with recursive counts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 13:26:12 -03:00
Lucas GuerraandClaude Sonnet 5 7683967650 feat(report): add logo and TLP classification badge to the recovery report
CI / Format and clippy (push) Successful in 2m13s
CI / Dependency audit (push) Successful in 12s
CI / Check desktop app (Linux) (push) Successful in 4m21s
CI / Tests (Linux) (push) Successful in 8m23s
The HTML/PDF report had no visual identity (no logo) and no sharing
classification. Embeds the Guará logo as a base64 data URI (so the
standalone export still renders offline, same approach as Sabiá's report)
and adds a TLP:AMBER badge next to the existing "Uso autorizado" one —
forensic recovery findings are sensitive and worth marking for limited
disclosure, same as any other Ciberfauna report.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-02 11:31:40 -03:00
35 changed files with 1284 additions and 52 deletions

No files matched your search

+16
View File
@@ -4,6 +4,22 @@
Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow SemVer.
## [1.5.0] - 2026-11-03
### Added
- **Update progress bar.** The in-app update shows a real download percentage bar followed by the verify/install/restart phases.
- **Delete saved sessions.** Each autosaved session in the sidebar has a delete button, plus a "delete all" button. Settings gained "Delete autosaved sessions after" (never, 7, 30 or 90 days), applied on startup. Sessions open in the app are never removed automatically.
### Fixed
- **Updating no longer freezes the app.** The update check and install ran on the UI thread; they now run in the background.
- **Pause and Stop respond right away.** The signature scan only checked for the request once per 8 MiB block; it now checks continuously, and the UI shows "Pausing…" immediately.
## [1.4.0] - 2026-11-03
### Added
- **Browse by folder.** A Folders view next to grid and list shows what was found one folder at a time, like a file manager: subfolders first with their file count and size, then the files, under a clickable breadcrumb. The sidebar folder tree navigates in this view, and filters still apply.
- **Recover whole folders or parts of them.** Folders and files are ticked with tri-state boxes that persist while navigating; a ticked folder takes everything inside it, and unticked subfolders or files stay out. Each ticked folder is recreated in the destination from itself down (`Documents/Clients/Project` → `Project/...`), with the usual hash manifest.
## [1.3.5] - 2026-10-31
### Added
+16
View File
@@ -4,6 +4,22 @@
Formato baseado em [Keep a Changelog](https://keepachangelog.com/pt-BR/1.1.0/); versões seguem SemVer.
## [1.5.0] - 2026-11-03
### Adicionado
- **Barra de progresso da atualização.** A atualização dentro do app mostra uma barra com a porcentagem real do download, seguida das fases de verificação, instalação e reinício.
- **Apagar sessões salvas.** Cada sessão salva sozinha na lateral tem um botão de apagar, além de um botão "apagar todas". As configurações ganharam "Apagar sessões salvas sozinhas após" (nunca, 7, 30 ou 90 dias), aplicado ao abrir. Sessões abertas no app nunca são removidas automaticamente.
### Corrigido
- **Atualizar não trava mais o app.** A verificação e a instalação rodavam na thread da interface; agora rodam em segundo plano.
- **Pausar e Parar respondem na hora.** A varredura por assinatura só checava o pedido a cada bloco de 8 MiB; agora checa continuamente, e a interface mostra "Pausando…" imediatamente.
## [1.4.0] - 2026-11-03
### Adicionado
- **Navegação por pastas.** Uma visualização Pastas, ao lado de grade e lista, mostra o que foi encontrado uma pasta por vez, como num gerenciador de arquivos: primeiro as subpastas, com número de arquivos e tamanho, depois os arquivos, sob um caminho clicável. A árvore de pastas da barra lateral navega nessa visualização, e os filtros continuam valendo.
- **Recuperar pastas inteiras ou partes delas.** Pastas e arquivos são marcados por caixas de três estados que continuam ao navegar; uma pasta marcada leva tudo o que está dentro dela, e subpastas ou arquivos desmarcados ficam de fora. Cada pasta marcada é recriada no destino a partir dela mesma (`Documentos/Clientes/Projeto` → `Projeto/...`), com o manifesto de hashes de sempre.
## [1.3.5] - 2026-10-31
### Adicionado
Generated
+2 -2
View File
@@ -416,7 +416,7 @@ dependencies = [
[[package]]
name = "guara-cli"
version = "1.3.5"
version = "1.5.0"
dependencies = [
"clap",
"ctrlc",
@@ -429,7 +429,7 @@ dependencies = [
[[package]]
name = "guara-core"
version = "1.3.5"
version = "1.5.0"
dependencies = [
"aes",
"argon2",
+1 -1
View File
@@ -3,7 +3,7 @@ resolver = "2"
members = ["crates/guara-core", "crates/guara-cli"]
[workspace.package]
version = "1.3.5"
version = "1.5.0"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://git.lucasrguerra.dev.br/ciberfauna/guara"
+4
View File
@@ -77,6 +77,10 @@ A desktop app (Tauri) in the style of a file manager, designed for when Guará f
<p align="center"><img src="docs/img/explorer-dark-en.png" width="640" alt="The explorer in the dark theme"> <img src="docs/img/settings-language-en.png" width="250" alt="Settings with the language selector"></p>
- **Thumbnail grid** or **list**, grouping by day or month and virtual scrolling for tens of thousands of files.
- **Folder browsing:** open what was found one folder at a time, like a file manager, and recover whole folders or only some subfolders and files, recreated from the ticked folder down.
<p align="center"><img src="docs/img/folders-light-en.png" width="720" alt="The Folders view: the root of the recovered files with DCIM ticked, Viagens partly ticked and the folder details on the right"></p>
- **Sidebar navigation** by type, real photo date (EXIF), folder, camera, confidence and GPS, with an option to hide duplicates.
- **Finder or Explorer style selection** and full-screen **quick look** (Space, Enter or double click).
- **Details panel** with preview, dates and metadata.
+4
View File
@@ -77,6 +77,10 @@ App desktop (Tauri) no estilo de um gerenciador de arquivos, pensado para quando
<p align="center"><img src="docs/img/explorer-dark-pt.png" width="640" alt="O explorador no tema escuro"> <img src="docs/img/settings-language-pt.png" width="250" alt="Configurações com o seletor de idioma"></p>
- **Grade de miniaturas** ou **lista**, agrupamento por dia ou mês e rolagem virtual para dezenas de milhares de arquivos.
- **Navegação por pastas:** abra o que foi encontrado uma pasta por vez, como num gerenciador de arquivos, e recupere pastas inteiras ou só algumas subpastas e arquivos, recriados a partir da pasta marcada.
<p align="center"><img src="docs/img/folders-light-pt.png" width="720" alt="A visualização Pastas: a raiz dos arquivos encontrados com DCIM marcada, Viagens parcialmente marcada e os detalhes da pasta à direita"></p>
- **Navegação lateral** por tipo, data real da foto (EXIF), pasta, câmera, confiança e GPS, com opção de ocultar duplicadas.
- **Seleção como no Finder ou Explorer** e **visualização rápida** em tela cheia (Espaço, Enter ou duplo clique).
- **Painel de detalhes** com pré-visualização, datas e metadados.
+2 -2
View File
@@ -1342,7 +1342,7 @@ dependencies = [
[[package]]
name = "guara-core"
version = "1.3.5"
version = "1.5.0"
dependencies = [
"aes",
"argon2",
@@ -1373,7 +1373,7 @@ dependencies = [
[[package]]
name = "guara-gui"
version = "1.3.5"
version = "1.5.0"
dependencies = [
"guara-core",
"libc",
+1 -1
View File
@@ -3,7 +3,7 @@
[package]
name = "guara-gui"
description = "Guará: graphical file recovery interface"
version = "1.3.5"
version = "1.5.0"
edition = "2021"
license = "MIT OR Apache-2.0"
authors = ["Guará contributors"]
+23 -7
View File
@@ -22,25 +22,41 @@ async fn rpc(
}
#[tauri::command]
fn update_check(state: tauri::State<'_, State>) -> Result<serde_json::Value, String> {
let status = state.0.update_check().map_err(|e| e.to_string())?;
async fn update_check(state: tauri::State<'_, State>) -> Result<serde_json::Value, String> {
let eng = state.0.clone();
tauri::async_runtime::spawn_blocking(move || {
let status = eng.update_check().map_err(|e| e.to_string())?;
serde_json::to_value(status).map_err(|e| e.to_string())
})
.await
.map_err(|e| e.to_string())?
}
#[tauri::command]
fn update_apply(app: tauri::AppHandle, state: tauri::State<'_, State>) -> Result<String, String> {
async fn update_apply(app: tauri::AppHandle, state: tauri::State<'_, State>) -> Result<String, String> {
use tauri::Emitter;
#[cfg(any(target_os = "linux", target_os = "macos"))]
let exe = elevated_exe().unwrap_or_else(|_| std::env::current_exe().unwrap_or_default());
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
let exe = std::env::current_exe().unwrap_or_default();
state
.0
.update_apply_desktop(&exe, move |phase| {
let _ = app.emit("update-progress", serde_json::json!({ "phase": phase }));
// Blocking download/install must not run on the UI thread, or the window freezes.
let eng = state.0.clone();
tauri::async_runtime::spawn_blocking(move || {
eng.update_apply_desktop(&exe, move |phase| {
let (name, pct) = match phase.split_once(':') {
Some((n, p)) => (n, p.parse::<u8>().ok()),
None => (phase, None),
};
let _ = app.emit(
"update-progress",
serde_json::json!({ "phase": name, "percent": pct }),
);
})
.map_err(|e| e.to_string())
})
.await
.map_err(|e| e.to_string())?
}
/// `true` when the process already has sufficient privileges to read raw disks.
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Guará",
"version": "1.3.5",
"version": "1.5.0",
"identifier": "dev.guara.app",
"build": {
"frontendDist": "../ui"
+20
View File
@@ -422,6 +422,21 @@ dialog.lightbox[open] { display: grid; }
.xp-insp .viewer { max-height: 38vh; min-height: 150px; }
.xp-ititle { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; } .xp-ititle b { overflow-wrap: anywhere; font-size: 15px; }
.xp-meta h5 { margin: 6px 0 6px; font-size: 12px; color: var(--text-3); font-weight: 600; }
/* folder browsing */
.xp-path { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; }
.xp-cpart { border: 0; background: none; color: var(--text-2); font: inherit; font-size: 14px; padding: 4px 6px; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.xp-cpart:hover { background: var(--surface-2); color: var(--text); }
.xp-cpart:last-child { color: var(--text); font-weight: 600; }
.xp-csep { color: var(--text-3); }
.xp-lth .xp-fico { color: var(--accent); background: var(--accent-soft); border-radius: 8px; }
.xp-dir .xp-lnm b { font-weight: 600; }
.xp-dir[data-state="mixed"] .xp-chk { opacity: 1; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M7 12h10'/%3E%3C/svg%3E") center / 14px no-repeat; }
.xp-lrow[data-cur="1"] { box-shadow: inset 0 0 0 2px var(--accent); }
.xp-folder-insp { display: grid; gap: 14px; padding: 20px 4px; }
.xp-folder-insp h3 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.xp-fbig { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 16px; color: var(--accent); background: var(--accent-soft); }
.xp-fbig svg { width: 34px; height: 34px; }
.xp-folder-insp .row { display: flex; gap: 8px; flex-wrap: wrap; }
.xp-multi { display: grid; gap: 12px; padding: 20px 4px; text-align: center; } .xp-multi b { font-size: 18px; }
.xp-insp-x { display: none; align-self: flex-end; }
.xp-veil { display: none; }
@@ -527,3 +542,8 @@ dialog.lightbox[open] { display: grid; }
.update-card .upd-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.update-card .sub { margin: 0; }
pre.upd-notes { max-height: 50vh; overflow: auto; white-space: pre-wrap; font-size: 13px; }
.update-card .upd-bar { margin-top: 10px; }
.list li.has-del { position: relative; }
.list li.has-del .del { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); opacity: 0; }
.list li.has-del:hover .del, .list li.has-del .del:focus-visible { opacity: 1; }
+59 -13
View File
@@ -53,7 +53,7 @@ document.querySelectorAll('[data-theme-pick]').forEach((b) => (b.onclick = async
// ------------------------------------------------------------------ settings
// (declared before use: `S` is defined further below, so the object lives here)
const SETTINGS = { theme: 'auto', lang: 'auto', ui_lang: null, notify: true, maps: false, updates: true };
const SETTINGS = { theme: 'auto', lang: 'auto', ui_lang: null, notify: true, maps: false, updates: true, session_retention_days: 0 };
async function saveSettings(patch) {
Object.assign(SETTINGS, patch);
try { await rpc('settings_set', SETTINGS); } catch { /* continue with local storage only */ }
@@ -201,11 +201,36 @@ function renderSide() {
const rl = $('#recentList');
rl.dataset.empty = 'Nada salvo ainda';
rl.innerHTML = (S.recent || []).map((r, i) => `
<li><button class="dev" data-r="${i}" title="${esc(r.path)}"><span class="ico">${icon('default')}</span>
<span><span class="t">${esc((r.target || '').split(/[\\/]/).pop() || 'Sessão')}</span><span class="s">${r.found.toLocaleString(LOC())} arquivos · ${esc(r.status)} · ${new Date(r.saved_at * 1000).toLocaleString(LOC(), { dateStyle: 'short', timeStyle: 'short' })}</span></span></button></li>`).join('');
<li class="has-del"><button class="dev" data-r="${i}" title="${esc(r.path)}"><span class="ico">${icon('default')}</span>
<span><span class="t">${esc((r.target || '').split(/[\\/]/).pop() || 'Sessão')}</span><span class="s">${r.found.toLocaleString(LOC())} arquivos · ${esc(r.status)} · ${new Date(r.saved_at * 1000).toLocaleString(LOC(), { dateStyle: 'short', timeStyle: 'short' })}</span></span></button><button class="icon-btn small del" data-del="${i}" title="Apagar esta sessão" aria-label="Apagar esta sessão"><svg viewBox="0 0 24 24" width="14" height="14"><path d="M6 6l12 12M18 6L6 18" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"/></svg></button></li>`).join('');
rl.querySelectorAll('.dev').forEach((b) => (b.onclick = () => openRecent(S.recent[+b.dataset.r])));
rl.querySelectorAll('.del').forEach((b) => (b.onclick = (e) => { e.stopPropagation(); deleteRecent(S.recent[+b.dataset.del]); }));
}
function confirmDlg({ title, text, ok }) {
return new Promise((resolve) => {
const d = $('#dlg');
d.innerHTML = `<form method="dialog"><h2>${esc(title)}</h2><p>${text}</p><menu><button class="btn" value="cancel">Cancelar</button><button class="btn danger" value="ok">${esc(ok)}</button></menu></form>`;
d.onclose = () => resolve(d.returnValue === 'ok');
d.showModal();
});
}
async function deleteRecent(r) {
if (!r) return;
const name = (r.target || '').split(/[\\/]/).pop() || 'Sessão';
if (!await confirmDlg({ title: 'Apagar sessão salva', text: `A sessão de <code>${esc(name)}</code> será apagada de vez. Os arquivos do disco não são afetados.`, ok: 'Apagar' })) return;
try { await rpc('session_delete', { path: r.path }); toast('Sessão apagada'); } catch (e) { toast(e.message); }
loadRecent();
}
$('#clearRecentBtn')?.addEventListener('click', async () => {
if (!(S.recent || []).length) { toast('Nada para apagar'); return; }
if (!await confirmDlg({ title: 'Apagar todas as sessões salvas', text: 'Todas as sessões salvas sozinhas serão apagadas de vez. Sessões abertas agora são mantidas.', ok: 'Apagar tudo' })) return;
try { const r = await rpc('sessions_prune', { all: true }); toast(`Sessões apagadas: ${r.removed}`); } catch (e) { toast(e.message); }
loadRecent();
});
async function loadRecent() {
try { S.recent = await rpc('sessions_list'); } catch { S.recent = []; }
renderSide();
@@ -590,7 +615,9 @@ function paintStatus() {
const rate = p.total && st.elapsed > 1 && p.done ? p.done / st.elapsed : 0;
const eta = rate && running ? dur((p.total - p.done) / rate) : null;
const enr = st.enriching ? `<span class="sub">Lendo datas e metadados das fotos… ${st.enriching.done.toLocaleString(LOC())}/${st.enriching.total.toLocaleString(LOC())}</span>` : '';
const buttons = running ? '<button class="btn sm" data-act="pause">Pausar</button><button class="btn sm danger" data-act="stop">Parar</button>'
const stopping = running && st.stopping;
const buttons = stopping ? '<button class="btn sm" disabled>Pausando…</button>'
: running ? '<button class="btn sm" data-act="pause">Pausar</button><button class="btn sm danger" data-act="stop">Parar</button>'
: st.status === 'paused' ? `<button class="btn sm primary" data-act="${st.source === false ? 'reconnect' : 'resume'}">${st.source === false ? 'Reconectar o disco' : 'Continuar'}</button><button class="btn sm" data-act="relink">Escolher a origem…</button>` : '';
const relink = st.source === false ? '<button class="btn sm primary" data-act="relink">Escolher a origem…</button>' : '';
const tools = relink + (!running && st.found ? '<button class="btn sm" data-act="csv">Exportar CSV</button><button class="btn sm" data-act="report">Relatório</button><button class="btn sm" data-act="save">Salvar sessão…</button>' : '');
@@ -651,8 +678,8 @@ async function chooseSource() {
async function onProgressClick(e) {
const act = e.target.closest('[data-act]')?.dataset.act;
if (!act) return;
if (act === 'pause') { await rpc('scan_pause', { job: S.job }); toast('Pausando…'); }
else if (act === 'stop') await rpc('scan_stop', { job: S.job });
if (act === 'pause') { await rpc('scan_pause', { job: S.job }); toast('Pausando…'); tick(); }
else if (act === 'stop') { await rpc('scan_stop', { job: S.job }); tick(); }
else if (act === 'resume') {
try { await rpc('scan_resume', { job: S.job }); stopPoll(); S.poll = setInterval(tick, 500); tick(); }
catch (err) { toast(err.message); chooseSource(); }
@@ -687,19 +714,25 @@ async function onProgressClick(e) {
}
async function recover(sel) {
// From folder browsing: each marked folder is recreated from itself down
// (a/b/Projeto -> Projeto/...), so there is no layout to choose.
const bySelection = !!sel.selection;
const f = await askForm({
title: 'Recuperar para…',
text: 'Escolha uma pasta em <b>outro disco</b>. O Guará nunca grava no disco de origem, para não sobrescrever o que ainda dá para salvar. <span class="sub">Se a recuperação for interrompida, escolha a mesma pasta de novo: o Guará pula o que já foi conferido.</span>',
text: 'Escolha uma pasta em <b>outro disco</b>. O Guará nunca grava no disco de origem, para não sobrescrever o que ainda dá para salvar. <span class="sub">Se a recuperação for interrompida, escolha a mesma pasta de novo: o Guará pula o que já foi conferido.</span>'
+ (bySelection ? ' <span class="sub">Cada pasta marcada é recriada no destino a partir dela mesma, com todas as subpastas. Arquivos marcados soltos vão para a raiz do destino.</span>' : '')
+ (bySelection && sel.filtered ? ' <span class="sub"><b>Atenção:</b> pastas marcadas são recuperadas inteiras; os filtros ativos não se aplicam a elas.</span>' : ''),
ok: 'Recuperar',
fields: [
{ name: 'dest', label: 'Pasta de destino', value: (S.defaults.home || '') + (S.defaults.sep || '/') + 'Guara-Recuperados', pick: { directory: true, multiple: false } },
{ name: 'layout', label: 'Organizar os arquivos', value: 'folders', options: [['folders', 'Pastas originais (e por tipo quando não há pasta)'], ['type', 'Por tipo (Fotos, Documentos, Vídeos...)'], ['date', 'Por data (ano e mês)'], ['flat', 'Tudo na mesma pasta']] },
...(bySelection ? [] : [{ name: 'layout', label: 'Organizar os arquivos', value: 'folders', options: [['folders', 'Pastas originais (e por tipo quando não há pasta)'], ['type', 'Por tipo (Fotos, Documentos, Vídeos...)'], ['date', 'Por data (ano e mês)'], ['flat', 'Tudo na mesma pasta']] }]),
],
});
if (!f || !f.dest) return;
const dest = f.dest;
const { filtered, ...target } = sel;
try {
const { job } = await rpc('recover_start', { job: S.job, dest, layout: f.layout, ...sel });
const { job } = await rpc('recover_start', { job: S.job, dest, layout: f.layout || 'folders', ...target });
watchAux(job, 'Recuperando arquivos', (st) => {
const r = st.report || {};
const ok = (r.recovered || []).length, bad = (r.failed || []).length;
@@ -747,9 +780,11 @@ $('#settingsBtn')?.addEventListener('click', () => {
<label class="fld"><span>Idioma</span><select class="select" name="lang"><option value="auto">Auto</option><option value="pt">Português</option><option value="en">English</option></select></label>
<label class="check"><input type="checkbox" name="notify" ${SETTINGS.notify ? 'checked' : ''}><span><b>Notificações</b><br><span class="sub">Avisar quando uma tarefa longa terminar</span></span></label>
<label class="check"><input type="checkbox" name="maps" ${SETTINGS.maps ? 'checked' : ''}><span><b>Mapas online</b><br><span class="sub">Mostrar mapas das fotos com GPS (usa a internet: baixa blocos do OpenStreetMap)</span></span></label>
<label class="fld"><span>Apagar sessões salvas sozinhas após</span><select class="select" name="retention"><option value="0">Nunca</option><option value="7">7 dias</option><option value="30">30 dias</option><option value="90">90 dias</option></select></label>
${tauri?.core?.invoke ? `<label class="check"><input type="checkbox" name="updates" ${SETTINGS.updates ? 'checked' : ''}><span><b>Atualizações automáticas</b><br><span class="sub">Ao abrir, consulta o Gitea para ver se há versão nova (uma consulta, sem enviar dados seus)</span><br><button type="button" class="btn sm" id="updNow">Verificar agora</button></span></label>` : ''}
<menu><button class="btn" value="cancel">Cancelar</button><button class="btn primary" value="ok">Salvar</button></menu></form>`;
d.querySelector('[name=lang]').value = SETTINGS.lang;
d.querySelector('[name=retention]').value = String([0, 7, 30, 90].includes(SETTINGS.session_retention_days) ? SETTINGS.session_retention_days : 0);
d.querySelector('#updNow')?.addEventListener('click', (e) => {
e.preventDefault();
if (UPD) applyUpdate();
@@ -757,11 +792,11 @@ $('#settingsBtn')?.addEventListener('click', () => {
});
d.onclose = () => {
if (d.returnValue !== 'ok') return;
const patch = { lang: d.querySelector('[name=lang]').value, notify: d.querySelector('[name=notify]').checked, maps: d.querySelector('[name=maps]').checked };
const patch = { lang: d.querySelector('[name=lang]').value, notify: d.querySelector('[name=notify]').checked, maps: d.querySelector('[name=maps]').checked, session_retention_days: +d.querySelector('[name=retention]').value };
if (d.querySelector('[name=updates]')) patch.updates = d.querySelector('[name=updates]').checked;
setLang(patch.lang);
patch.ui_lang = currentLang();
saveSettings(patch);
saveSettings(patch).then(() => rpc('sessions_prune', {}).then(loadRecent).catch(() => {}));
EX?.relang?.();
toast('Salvo');
};
@@ -779,7 +814,15 @@ async function applyUpdate() {
updating = true;
const updApply = $('#updApply');
const updNow = $('#updNow');
const setPhase = (txt) => {
const setPhase = (txt, pct) => {
const card = $('#updateCard');
if (card) {
let bar = card.querySelector('.upd-bar');
if (!bar) { bar = document.createElement('div'); bar.className = 'bar upd-bar'; bar.innerHTML = '<i></i>'; card.appendChild(bar); }
bar.classList.toggle('indet', pct == null);
bar.firstChild.style.width = pct == null ? '35%' : `${pct}%`;
}
if (pct != null) txt = `${txt} ${pct}%`;
if (updApply) { updApply.disabled = true; updApply.textContent = txt; }
if (updNow) { updNow.disabled = true; updNow.textContent = txt; }
};
@@ -790,7 +833,8 @@ async function applyUpdate() {
try {
unlisten = await tauri.event.listen('update-progress', (event) => {
const phase = event.payload?.phase;
if (phase === 'downloading') setPhase('Baixando a atualização…');
const pct = event.payload?.percent;
if (phase === 'downloading') setPhase('Baixando a atualização…', pct);
else if (phase === 'verifying') setPhase('Verificando integridade…');
else if (phase === 'installing') setPhase('Instalando a atualização…');
else if (phase === 'restarting') setPhase('Reiniciando…');
@@ -803,6 +847,7 @@ async function applyUpdate() {
setPhase('Atualização concluída');
} catch (e) {
updating = false;
$('#updateCard .upd-bar')?.remove();
if (updApply) { updApply.disabled = false; updApply.textContent = 'Atualizar agora'; }
if (updNow) { updNow.disabled = false; updNow.textContent = UPD?.version ? `atualizar para ${UPD.version}` : 'Verificar agora'; }
toast(`Falha na atualização: ${e}`);
@@ -908,6 +953,7 @@ function watchClose() {
return;
}
await loadDevices();
try { await rpc('sessions_prune', {}); } catch { /* retention is best-effort */ }
await loadRecent();
renderHome();
})();
+206 -8
View File
@@ -4,7 +4,7 @@
// fullscreen quick look.
import { renderPreview, kindOf, KIND_LABEL } from './preview.js';
import { LOC } from './i18n.js';
import { LOC, tr } from './i18n.js';
const CAT = {
image: ['Fotos', '🖼'], document: ['Documentos', '📄'], video: ['Vídeos', '🎞'], audio: ['Áudio', '🎵'],
@@ -28,6 +28,8 @@ const I = {
pin: svg('<path d="M12 21s-6-5.3-6-10a6 6 0 1 1 12 0c0 4.7-6 10-6 10z"/><circle cx="12" cy="11" r="2"/>', 14),
warn: svg('<path d="M12 3l10 18H2z"/><path d="M12 10v5M12 18v.01"/>', 22),
close: svg('<path d="M6 6l12 12M18 6L6 18"/>', 20),
folder: svg('<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>'),
folderBig: svg('<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>', 22),
};
export function createExplorer(deps) {
@@ -62,6 +64,14 @@ export function createExplorer(deps) {
lastFound: -1,
wasEnriching: false,
status: null,
// folder browsing: current folder ('' = root, '@carved' = found by
// signature), its subfolders, and a selection of its own that keeps
// marked and unmarked folders and files across levels
path: '',
dirs: [],
curDir: null,
fs: { folders: new Set(), xfolders: new Set(), files: new Map(), xfiles: new Map() },
fsCount: null,
};
try {
E.view = localStorage.getItem('guara-view') || 'grid';
@@ -74,7 +84,7 @@ export function createExplorer(deps) {
<div class="xp-crumb" id="xpCrumb"></div>
<input class="input xp-q" id="xpQ" type="search" placeholder="Buscar por nome, pasta ou câmera" aria-label="Buscar">
<select class="select" id="xpSort" aria-label="Ordenar">${SORTS.map(([k, n]) => `<option value="${k}">${n}</option>`).join('')}</select>
<div class="theme-switch" role="group" aria-label="Modo de exibição"><button data-view="grid" aria-label="Grade" title="Grade de miniaturas">${I.grid}</button><button data-view="list" aria-label="Lista" title="Lista">${I.list}</button></div>
<div class="theme-switch" role="group" aria-label="Modo de exibição"><button data-view="grid" aria-label="Grade" title="Grade de miniaturas">${I.grid}</button><button data-view="list" aria-label="Lista" title="Lista">${I.list}</button><button data-view="folders" aria-label="Pastas" title="Navegar pelas pastas">${I.folder}</button></div>
<input type="range" id="xpSize" min="100" max="300" step="4" aria-label="Tamanho das miniaturas">
</div>
<aside class="xp-nav" id="xpNav" aria-label="Navegação"></aside>
@@ -112,7 +122,10 @@ export function createExplorer(deps) {
};
const anyFilter = () => Object.entries(E.filters).some(([k, v]) => (k === 'query' ? !!v : !!v));
const folderMode = () => E.view === 'folders';
async function reload() {
if (folderMode()) return reloadFolder();
const token = ++E.reloadToken;
E.lastReload = Date.now();
const base = { ...toQuery(), sort: E.sort };
@@ -132,6 +145,29 @@ export function createExplorer(deps) {
paintAll();
}
async function reloadFolder() {
const token = ++E.reloadToken;
E.lastReload = Date.now();
const { folder, ...filters } = toQuery();
const base = { ...filters, sort: E.sort === 'date' || E.sort === 'date_asc' ? E.sort : E.sort || 'name' };
let items = [], total = 0, dirs = null;
for (;;) {
let r;
try { r = await rpc('browse', { job, path: E.path, query: { ...base, offset: items.length, limit: 2000 } }); } catch (e) { toast(e.message); return; }
if (token !== E.reloadToken) return;
if (!dirs) dirs = r.folders;
items = items.concat(r.files);
total = r.total_files;
if (!r.files.length || items.length >= total || items.length >= 30000) break;
}
E.dirs = dirs || [];
E.items = items;
E.total = total;
paintCrumb();
relayout();
paintAll();
}
async function loadFacets() {
try { E.facets = await rpc('facets', { job }); } catch { return; }
paintNav();
@@ -157,7 +193,7 @@ export function createExplorer(deps) {
function geometry() {
const W = Math.max(200, scroll.clientWidth - PAD * 2);
if (E.view === 'list') return { W, cols: 1, tw: W, cap: 0, rowH: 54 };
if (E.view === 'list' || E.view === 'folders') return { W, cols: 1, tw: W, cap: 0, rowH: 54 };
const T = E.tile;
const cols = Math.max(1, Math.floor((W + GAP) / (T + GAP)));
const tw = Math.floor((W - GAP * (cols - 1)) / cols);
@@ -176,6 +212,9 @@ export function createExplorer(deps) {
}
const rows = [];
let y = PAD;
if (folderMode()) {
E.dirs.forEach((_, d) => { rows.push({ t: 'dir', y, h: G.rowH, d }); y += G.rowH; });
}
let cur = null, rowItems = [];
const flush = () => {
if (rowItems.length) { rows.push({ t: 'row', y, h: G.rowH, idx: rowItems }); y += G.rowH; rowItems = []; }
@@ -238,7 +277,7 @@ export function createExplorer(deps) {
el.style.top = `${row.y}px`;
el.style.height = `${row.h}px`;
el.dataset.ri = ri;
el.innerHTML = row.t === 'head' ? headHtml(row) : row.idx.map((i) => (E.view === 'list' ? listHtml(i) : tileHtml(i))).join('');
el.innerHTML = row.t === 'head' ? headHtml(row) : row.t === 'dir' ? dirHtml(row.d) : row.idx.map((i) => (E.view === 'grid' ? tileHtml(i) : listHtml(i))).join('');
E.rendered.set(ri, el);
frag.appendChild(el);
}
@@ -246,7 +285,82 @@ export function createExplorer(deps) {
}
// ------------------------------------------------------------ items
const isSel = (id) => E.allFiltered || E.sel.has(id);
// `p` is inside `d` (or is `d`); '' holds everything, '@carved' only itself.
const under = (p, d) => d === '' || p === d || (d !== '@carved' && p.startsWith(d + '/'));
// Deepest marked/unmarked folder holding `p` decides, as in the core.
const covered = (p) => {
let best = null;
for (const d of E.fs.folders) if (under(p, d) && (best == null || d.length > best[0].length)) best = [d, true];
for (const d of E.fs.xfolders) if (under(p, d) && (best == null || d.length >= best[0].length)) best = [d, false];
return !!best && best[1];
};
const dirOf = (it) => (it.origin === 'carved' ? '@carved' : (it.dir || '').replace(/^\/+|\/+$/g, ''));
const fileOn = (it) => !E.fs.xfiles.has(it.id) && (E.fs.files.has(it.id) || covered(dirOf(it)));
// 'on', 'off' or 'mixed' for a folder row
const dirState = (d) => {
const on = covered(d);
const inside = (p) => p !== d && under(p, d);
const marks = on
? [...E.fs.xfolders].some(inside) || [...E.fs.xfiles.values()].some((p) => under(p, d)) || [...E.fs.folders].some(inside)
: [...E.fs.folders].some(inside) || [...E.fs.files.values()].some((p) => under(p, d));
return marks ? 'mixed' : on ? 'on' : 'off';
};
const fsEmpty = () => !E.fs.folders.size && !E.fs.files.size;
const dropInside = (d) => {
for (const k of [...E.fs.folders]) if (under(k, d)) E.fs.folders.delete(k);
for (const k of [...E.fs.xfolders]) if (under(k, d)) E.fs.xfolders.delete(k);
for (const [id, p] of [...E.fs.files]) if (under(p, d)) E.fs.files.delete(id);
for (const [id, p] of [...E.fs.xfiles]) if (under(p, d)) E.fs.xfiles.delete(id);
};
// Like a file manager's tri-state box: a fully marked folder is unmarked;
// an unmarked or partly marked one becomes fully marked.
function toggleDir(d) {
const unmark = dirState(d) === 'on';
dropInside(d);
if (unmark) { if (covered(d)) E.fs.xfolders.add(d); } else if (!covered(d)) E.fs.folders.add(d);
fsChanged();
}
function toggleFile(it) {
const p = dirOf(it);
if (fileOn(it)) { E.fs.files.delete(it.id); if (covered(p)) E.fs.xfiles.set(it.id, p); } else { E.fs.xfiles.delete(it.id); if (!covered(p)) E.fs.files.set(it.id, p); }
fsChanged();
}
const fsSelection = () => ({
folders: [...E.fs.folders], ids: [...E.fs.files.keys()], exclude: [...E.fs.xfiles.keys()], exclude_folders: [...E.fs.xfolders],
});
let countT;
function fsChanged() {
paintSel();
clearTimeout(countT);
if (fsEmpty()) { E.fsCount = null; paintActions(); return; }
countT = setTimeout(async () => {
try { E.fsCount = await rpc('selection_count', { job, selection: fsSelection() }); } catch { E.fsCount = null; }
paintActions();
}, 120);
}
function goTo(path) {
E.path = path; E.curDir = null; E.curId = null;
scroll.scrollTop = 0;
paintInspector();
reload();
}
const parentOf = (p) => (p === '@carved' || !p.includes('/') ? '' : p.slice(0, p.lastIndexOf('/')));
const dirLabel = (p) => (p === '' ? 'Raiz' : p === '@carved' ? 'Por assinatura' : p.split('/').pop());
function dirHtml(d) {
const it = E.dirs[d];
const st = dirState(it.path);
return `<div class="xp-lrow xp-dir" role="option" data-dir="${d}" aria-selected="${st === 'on'}" data-state="${st}" ${E.curDir === it.path ? 'data-cur="1"' : ''} title="${esc(it.path === '@carved' ? 'Arquivos encontrados por assinatura, sem pasta conhecida' : it.path)}">
<span class="xp-chk" data-chk="1" aria-hidden="true"></span><div class="xp-lth"><span class="xp-lico xp-fico">${I.folderBig}</span></div>
<div class="xp-lnm"><b>${esc(it.name)}</b><small>${it.files.toLocaleString(LOC())} ${tr(it.files === 1 ? 'arquivo' : 'arquivos')}</small></div>
<span class="xp-lcol"></span><span class="xp-lcol num">${human(it.bytes)}</span><span></span>
</div>`;
}
const isSel = (id) => {
if (folderMode()) { const it = E.items[idxOf(id)]; return !!it && fileOn(it); }
return E.allFiltered || E.sel.has(id);
};
function headHtml(row) {
return `<div class="xp-head"><b>${esc(dayLabel(row.key))}</b><small>${row.count} ${row.count === 1 ? 'item' : 'itens'}</small><button class="xp-hsel" data-hsel="${row.start}" data-n="${row.count}" aria-label="Selecionar este grupo">Selecionar grupo</button></div>`;
@@ -310,7 +424,15 @@ export function createExplorer(deps) {
el.setAttribute('aria-selected', String(isSel(id)));
if (E.curId === id) el.dataset.cur = '1'; else delete el.dataset.cur;
};
scroll.querySelectorAll('.xp-tile, .xp-lrow').forEach(set);
scroll.querySelectorAll('.xp-tile, .xp-lrow:not(.xp-dir)').forEach(set);
scroll.querySelectorAll('.xp-dir').forEach((el) => {
const d = E.dirs[+el.dataset.dir];
if (!d) return;
const st = dirState(d.path);
el.dataset.state = st;
el.setAttribute('aria-selected', String(st === 'on'));
if (E.curDir === d.path) el.dataset.cur = '1'; else delete el.dataset.cur;
});
paintActions();
}
@@ -353,6 +475,21 @@ export function createExplorer(deps) {
new ResizeObserver(() => { if (Math.abs(geometry().W - G.W) > 1 || geometry().cols !== G.cols) relayout(); else renderWindow(); }).observe(scroll);
scroll.addEventListener('click', (e) => {
const dr = e.target.closest('.xp-dir');
if (dr) {
const d = E.dirs[+dr.dataset.dir];
if (e.target.closest('[data-chk]') || e.ctrlKey || e.metaKey) toggleDir(d.path);
else { E.curDir = d.path; E.curId = null; paintSel(); paintInspector(); }
return;
}
if (folderMode()) {
const el = e.target.closest('.xp-lrow');
if (!el) return;
const it = E.items[+el.dataset.i];
if (e.target.closest('[data-chk]') || e.ctrlKey || e.metaKey) toggleFile(it);
else { E.curDir = null; E.curId = it.id; paintSel(); schedInspector(); }
return;
}
const hs = e.target.closest('[data-hsel]');
if (hs) {
const start = +hs.dataset.hsel, n = +hs.dataset.n;
@@ -368,10 +505,24 @@ export function createExplorer(deps) {
else setCursor(i, { extend: e.shiftKey, toggle: e.ctrlKey || e.metaKey });
});
scroll.addEventListener('dblclick', (e) => {
const dr = e.target.closest('.xp-dir');
if (dr) { if (!e.target.closest('[data-chk]')) goTo(E.dirs[+dr.dataset.dir].path); return; }
if (folderMode()) {
const el = e.target.closest('.xp-lrow');
if (el && !e.target.closest('[data-chk]')) openLightbox(+el.dataset.i);
return;
}
const el = e.target.closest('.xp-tile, .xp-lrow');
if (el) { setCursor(+el.dataset.i); openLightbox(+el.dataset.i); }
});
scroll.addEventListener('keydown', (e) => {
if (folderMode()) {
if ((e.key === 'Backspace' || (e.altKey && e.key === 'ArrowUp')) && E.path !== '') { e.preventDefault(); goTo(parentOf(E.path)); return; }
if (e.key === 'Enter' && E.curDir != null) { e.preventDefault(); goTo(E.curDir); return; }
if (e.key === ' ' && E.curDir != null) { e.preventDefault(); toggleDir(E.curDir); return; }
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'a') { e.preventDefault(); toggleDir(E.path); return; }
if (e.key === 'Escape') { E.fs = { folders: new Set(), xfolders: new Set(), files: new Map(), xfiles: new Map() }; fsChanged(); return; }
}
if (!E.items.length) return;
let i = idxOf(E.curId);
if (i < 0) i = 0;
@@ -389,6 +540,19 @@ export function createExplorer(deps) {
// ------------------------------------------------------------ action bar
function paintActions() {
if (folderMode()) {
const c = E.fsCount;
const here = dirState(E.path);
const html = !fsEmpty()
? `<span class="info">${c ? `<b>${c.files.toLocaleString(LOC())}</b> ${tr(c.files === 1 ? 'arquivo' : 'arquivos')} · ${human(c.bytes)}` : 'Calculando seleção…'}</span>
<button class="btn sm" data-a="clear">Limpar seleção</button>
${here !== 'on' ? `<button class="btn sm" data-a="here">Marcar esta pasta</button>` : ''}
<button class="btn primary" data-a="frec" ${c && c.files ? '' : 'disabled'}>Recuperar seleção</button>`
: `<span class="info">${E.dirs.length.toLocaleString(LOC())} ${E.dirs.length === 1 ? 'pasta' : 'pastas'} · ${E.total.toLocaleString(LOC())} ${E.total === 1 ? 'arquivo' : 'arquivos'} aqui</span>
${E.dirs.length || E.total ? '<button class="btn primary" data-a="here">Marcar esta pasta</button>' : ''}`;
if (actions._h !== html) { actions._h = html; actions.innerHTML = html; }
return;
}
const n = selCount();
const html = n
? `<span class="info"><b>${n.toLocaleString(LOC())}</b> selecionado${n === 1 ? '' : 's'}${E.allFiltered ? ' (todos desta vista)' : ''}</span>
@@ -401,6 +565,9 @@ export function createExplorer(deps) {
}
actions.addEventListener('click', (e) => {
const a = e.target.closest('[data-a]')?.dataset.a;
if (folderMode() && a === 'clear') { E.fs = { folders: new Set(), xfolders: new Set(), files: new Map(), xfiles: new Map() }; fsChanged(); return; }
if (a === 'here') { if (dirState(E.path) !== 'on') { dropInside(E.path); if (!covered(E.path)) E.fs.folders.add(E.path); fsChanged(); } return; }
if (a === 'frec') { onRecover({ selection: fsSelection(), filtered: anyFilter() }); return; }
if (a === 'clear') { E.sel = new Set(); E.allFiltered = false; paintSel(); }
else if (a === 'all') { E.allFiltered = true; paintSel(); }
else if (a === 'rec') onRecover(E.allFiltered ? { filter: toQuery() } : { ids: [...E.sel] });
@@ -461,6 +628,12 @@ export function createExplorer(deps) {
if (!b) return;
const F = E.filters;
const f = b.dataset.f, v = b.dataset.v;
if (folderMode() && f === 'folder') {
if (!v.startsWith('@')) E.expanded.add('d' + v);
nav._h = null; paintNav();
root.classList.remove('show-nav');
return goTo(v === '@raiz' ? '' : v);
}
if (f === 'all') clearFilters(false);
else if (f === 'year') { const same = F.year === +v && !F.month; F.year = same ? null : +v; F.month = null; F.undated = false; E.expanded.add('y' + v); }
else if (f === 'month') { const same = F.year === +b.dataset.y && F.month === +v; F.year = same ? null : +b.dataset.y; F.month = same ? null : +v; F.undated = false; }
@@ -490,6 +663,12 @@ export function createExplorer(deps) {
}
function paintCrumb() {
if (folderMode()) {
const parts = E.path === '' ? [] : E.path === '@carved' ? ['@carved'] : E.path.split('/').map((_, i, a) => a.slice(0, i + 1).join('/'));
const link = (p, label) => `<button class="xp-cpart" data-go="${esc(p)}">${esc(label)}</button>`;
$('#xpCrumb').innerHTML = `<nav class="xp-path" aria-label="Pasta atual">${[link('', 'Raiz'), ...parts.map((p) => link(p, dirLabel(p)))].join('<span class="xp-csep">›</span>')}</nav>`;
return;
}
const F = E.filters, parts = [];
if (F.category) parts.push(CAT[F.category][0]);
if (F.year) parts.push(String(F.year));
@@ -528,6 +707,11 @@ export function createExplorer(deps) {
changed();
});
$('#xpCrumb').addEventListener('click', (e) => {
const b = e.target.closest('[data-go]');
if (b && folderMode()) goTo(b.dataset.go);
});
// ------------------------------------------------------------ top bar
let qt;
$('#xpQ').addEventListener('input', (e) => { clearTimeout(qt); qt = setTimeout(() => { E.filters.query = e.target.value.trim(); changed(); }, 250); });
@@ -538,9 +722,11 @@ export function createExplorer(deps) {
$('#xpSize').style.display = E.view === 'grid' ? '' : 'none';
};
host.querySelectorAll('button[data-view]').forEach((b) => (b.onclick = () => {
const was = folderMode();
E.view = b.dataset.view;
try { localStorage.setItem('guara-view', E.view); } catch { /* */ }
paintView(); relayout();
paintView();
if (was !== folderMode()) { E.curId = null; E.curDir = null; E.dirs = []; paintCrumb(); paintInspector(); actions._h = null; reload(); } else relayout();
}));
$('#xpSize').addEventListener('input', (e) => {
E.tile = +e.target.value;
@@ -561,7 +747,17 @@ export function createExplorer(deps) {
function paintInspector() {
stopPv?.(); stopPv = null;
const n = selCount();
if (folderMode() && E.curDir != null) {
const d = E.dirs.find((x) => x.path === E.curDir);
const close = `<button class="icon-btn xp-insp-x" data-i="close" aria-label="Fechar">${I.close}</button>`;
if (d) {
insp.innerHTML = `${close}<div class="xp-folder-insp"><div class="xp-fbig">${I.folderBig}</div><h3>${esc(d.name)}</h3>
<dl class="kv"><dt>Caminho</dt><dd>${esc(d.path === '@carved' ? 'Encontrados por assinatura (sem pasta conhecida)' : d.path)}</dd><dt>Arquivos</dt><dd>${d.files.toLocaleString(LOC())}</dd><dt>Tamanho</dt><dd>${human(d.bytes)}</dd></dl>
<div class="row"><button class="btn" data-i="open">Abrir pasta</button><button class="btn primary" data-i="mark">${dirState(d.path) === 'on' ? 'Desmarcar pasta' : 'Marcar pasta inteira'}</button></div></div>`;
return;
}
}
const n = folderMode() ? 0 : selCount();
const it = E.items[idxOf(E.curId)];
const close = `<button class="icon-btn xp-insp-x" data-i="close" aria-label="Fechar">${I.close}</button>`;
if (n > 1) {
@@ -623,6 +819,8 @@ export function createExplorer(deps) {
else if (a === 'rec') onRecover(E.allFiltered ? { filter: toQuery() } : { ids: [...E.sel] });
else if (a === 'clear') { E.sel = new Set(); E.allFiltered = false; paintSel(); paintInspector(); }
else if (a === 'close') root.classList.remove('show-insp');
else if (a === 'open' && E.curDir != null) goTo(E.curDir);
else if (a === 'mark' && E.curDir != null) { toggleDir(E.curDir); paintInspector(); }
});
// ------------------------------------------------------------ fullscreen
+37
View File
@@ -598,4 +598,41 @@ export const EN = {
'Reiniciando…': 'Restarting…',
'Atualização concluída': 'Update completed',
'Falha na atualização: {n}': 'Update failed: {n}',
'Cada pasta marcada é recriada no destino a partir dela mesma, com todas as subpastas. Arquivos marcados soltos vão para a raiz do destino.': 'Each marked folder is recreated in the destination from itself down, with all its subfolders. Files marked on their own go to the root of the destination.',
'Atenção:': 'Note:',
'pastas marcadas são recuperadas inteiras; os filtros ativos não se aplicam a elas.': 'marked folders are recovered whole; the active filters do not apply to them.',
'Navegar pelas pastas': 'Browse folders',
'Arquivos encontrados por assinatura, sem pasta conhecida': 'Files found by signature, with no known folder',
'Calculando seleção…': 'Counting the selection…',
'Marcar esta pasta': 'Mark this folder',
'{n} {n} · {n} {n} aqui': '{n} {n} · {n} {n} here',
'Pasta atual': 'Current folder',
'Encontrados por assinatura (sem pasta conhecida)': 'Found by signature (no known folder)',
'Desmarcar pasta': 'Unmark folder',
'Marcar pasta inteira': 'Mark whole folder',
'Abrir pasta': 'Open folder',
'Recuperar seleção': 'Recover selection',
'Caminho': 'Path',
'Arquivos': 'Files',
'arquivo': 'file',
'pastas': 'folders',
'{n} arquivo': '{n} file',
'{n} arquivos': '{n} files',
'{n} {n} · {n}': '{n} {n} · {n}',
'Apagar esta sessão': 'Delete this session',
'Apagar todas as sessões salvas sozinhas': 'Delete all autosaved sessions',
'Apagar sessão salva': 'Delete saved session',
'Apagar': 'Delete',
'Apagar tudo': 'Delete all',
'Apagar todas as sessões salvas': 'Delete all saved sessions',
'Todas as sessões salvas sozinhas serão apagadas de vez. Sessões abertas agora são mantidas.': 'All autosaved sessions will be permanently deleted. Sessions currently open are kept.',
'Sessão apagada': 'Session deleted',
'Nada para apagar': 'Nothing to delete',
'Apagar sessões salvas sozinhas após': 'Delete autosaved sessions after',
'Nunca': 'Never',
'7 dias': '7 days',
'30 dias': '30 days',
'90 dias': '90 days',
'será apagada de vez. Os arquivos do disco não são afetados.': 'will be permanently deleted. Files on the disk are not affected.',
'Sessões apagadas: {n}': 'Sessions deleted: {n}',
};
+1 -1
View File
@@ -24,7 +24,7 @@
<button class="side-action" id="openImageBtn"><svg viewBox="0 0 24 24" width="18" height="18"><path d="M4 7a2 2 0 0 1 2-2h4l2 2h6a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" stroke="currentColor" stroke-width="1.8" fill="none"/></svg>Abrir arquivo de imagem…</button>
<div class="side-title">Sessões</div>
<ul id="sessionList" class="list"></ul>
<div class="side-title">Recentes <small style="font-weight:400;text-transform:none;letter-spacing:0">(salvas sozinhas)</small></div>
<div class="side-title">Recentes <small style="font-weight:400;text-transform:none;letter-spacing:0">(salvas sozinhas)</small> <button class="icon-btn small" id="clearRecentBtn" title="Apagar todas as sessões salvas sozinhas" aria-label="Apagar todas as sessões salvas sozinhas"><svg viewBox="0 0 24 24" width="16" height="16"><path d="M5 7h14M10 7V5h4v2m-6 0l1 12h6l1-12" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg></button></div>
<ul id="recentList" class="list"></ul>
<button class="side-action" id="loadSessionBtn"><svg viewBox="0 0 24 24" width="18" height="18"><path d="M12 4v11m0 0l-4-4m4 4l4-4M5 20h14" stroke="currentColor" stroke-width="1.8" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>Abrir sessão salva…</button>
</nav>
+1 -1
View File
@@ -812,7 +812,7 @@ fn recover_job(
filter.organize
))?;
let rj = eng
.start_recover(scan_job, ids, Some(q), dest, layout)
.start_recover(scan_job, ids, Some(q), None, dest, layout)
.map_err(s)?;
let st = wait(eng, &rj, None)?;
eprintln!();
+16
View File
@@ -64,7 +64,19 @@ pub fn carve_range(
let scan_len = got.min(CHUNK).min((end - pos) as usize);
ev.chunk(pos, &buf[..scan_len]);
let mut i = 0usize;
let mut since_check = 0u32;
while i < scan_len {
// Pause/stop must take effect within a fraction of a second even on slow media,
// not only at 8 MiB chunk boundaries. The chunk is reprocessed on resume (hits at
// offsets already found are skipped by the caller).
since_check += 1;
if since_check >= 2048 {
since_check = 0;
if cancelled() {
*next = pos;
return CarveEnd::Cancelled;
}
}
let abs = pos + i as u64;
if abs < skip_until {
i += SECTOR as usize;
@@ -78,6 +90,10 @@ pub fn carve_range(
let allowed = cfg.categories.is_empty()
|| cfg.categories.contains(&category_for_ext(hit.ext));
if hit.len >= MIN_LEN && allowed {
if cancelled() {
*next = pos;
return CarveEnd::Cancelled;
}
let action = ev.hit(abs, &hit);
match action {
HitAction::Skip if hit.confidence != crate::types::Confidence::Low => {
+311
View File
@@ -170,6 +170,140 @@ pub fn item_json(f: &Found) -> Value {
})
}
/// Folder a file belongs to for browsing: `None` for signature-carved files,
/// `""` for the volume root.
fn browse_dir(f: &Found) -> Option<&str> {
if f.origin == Origin::Carved {
return None;
}
Some(f.dir.as_deref().unwrap_or("").trim_matches('/'))
}
/// One level of the folder tree: the direct subfolders of `path` (with file and
/// byte totals over everything below them) and the files directly inside it,
/// paginated. `path` is `""` for the root or `"@carved"` for files found by
/// signature, which have no folder. Filters in `q` apply; its `folder` is ignored.
pub fn browse(found: &[Found], path: &str, q: &Query) -> Value {
let path = path.trim_matches('/');
let q = Query {
folder: None,
..q.clone()
};
let selected = q.select(found);
let mut folders: BTreeMap<&str, (u64, u64)> = BTreeMap::new();
let mut files: Vec<&Found> = Vec::new();
let mut carved = (0u64, 0u64);
for f in selected {
let Some(dir) = browse_dir(f) else {
if path == "@carved" {
files.push(f);
} else if path.is_empty() {
carved.0 += 1;
carved.1 += f.size;
}
continue;
};
if dir == path {
files.push(f);
continue;
}
let rest = if path.is_empty() {
dir
} else if let Some(rest) = dir.strip_prefix(path).and_then(|r| r.strip_prefix('/')) {
rest
} else {
continue;
};
let child = rest.split('/').next().unwrap_or(rest);
let child_path = &dir[..dir.len() - rest.len() + child.len()];
let entry = folders.entry(child_path).or_default();
entry.0 += 1;
entry.1 += f.size;
}
let mut out: Vec<Value> = folders
.iter()
.map(|(p, (n, bytes))| {
json!({ "name": p.rsplit('/').next().unwrap_or(p), "path": p, "files": n, "bytes": bytes })
})
.collect();
if carved.0 > 0 {
out.push(json!({ "name": "Por assinatura", "path": "@carved", "files": carved.0, "bytes": carved.1 }));
}
sort_items(&mut files, Some(q.sort.as_deref().unwrap_or("name")));
let total = files.len();
let page: Vec<Value> = files
.into_iter()
.skip(q.offset)
.take(q.limit.clamp(1, 5000))
.map(item_json)
.collect();
json!({ "path": path, "folders": out, "files": page, "total_files": total })
}
/// What the user marked in folder browsing: whole folders (recursive; `""` is
/// everything, `"@carved"` the files found by signature), single files, and
/// files or subfolders unmarked inside a marked folder.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Selection {
#[serde(default)]
pub folders: Vec<String>,
#[serde(default)]
pub ids: Vec<u64>,
#[serde(default)]
pub exclude: Vec<u64>,
#[serde(default)]
pub exclude_folders: Vec<String>,
}
/// Whether `f` is inside the browsing folder `folder` (recursively).
pub fn in_folder(f: &Found, folder: &str) -> bool {
let folder = folder.trim_matches('/');
if folder.is_empty() {
return true;
}
match browse_dir(f) {
None => folder == "@carved",
Some(dir) => dir == folder || dir.strip_prefix(folder).is_some_and(|r| r.starts_with('/')),
}
}
/// Files a selection resolves to, in discovery order. For each file the
/// deepest marked or unmarked folder holding it decides; marked folders take
/// everything inside them, whatever filters the view had. A file marked on its
/// own is in, and an excluded id always wins.
pub fn resolve_selection<'a>(found: &'a [Found], sel: &Selection) -> Vec<&'a Found> {
let ids: std::collections::HashSet<u64> = sel.ids.iter().copied().collect();
let exclude: std::collections::HashSet<u64> = sel.exclude.iter().copied().collect();
let marks: Vec<(&str, bool)> = sel
.folders
.iter()
.map(|d| (d.trim_matches('/'), true))
.chain(
sel.exclude_folders
.iter()
.map(|d| (d.trim_matches('/'), false)),
)
.collect();
found
.iter()
.filter(|f| !exclude.contains(&f.id))
.filter(|f| {
ids.contains(&f.id)
|| marks
.iter()
.filter(|(d, _)| in_folder(f, d))
.max_by_key(|(d, included)| (d.len(), !included))
.is_some_and(|(_, included)| *included)
})
.collect()
}
/// Files and bytes a selection resolves to.
pub fn selection_count(found: &[Found], sel: &Selection) -> Value {
let files = resolve_selection(found, sel);
json!({ "files": files.len(), "bytes": files.iter().map(|f| f.size).sum::<u64>() })
}
/// Facet counts for sidebar navigation.
pub fn facets(found: &[Found]) -> Value {
let mut cats: HashMap<&'static str, usize> = HashMap::new();
@@ -375,3 +509,180 @@ pub fn quick_sig(src: &dyn crate::source::Source, f: &Found) -> Option<u64> {
}
Some(h)
}
#[cfg(test)]
mod tests {
use super::*;
fn sample() -> Vec<Found> {
vec![
Found::test_file(1, "DCIM/100CANON", "a.jpg", 100),
Found::test_file(2, "DCIM", "b.jpg", 10),
Found::test_file(3, "", "x.txt", 5),
Found::test_carved(4, "c.jpg", 7),
Found::test_file(5, "DCIM/100CANON", "notes.txt", 1),
]
}
fn folders(v: &Value) -> Vec<(String, u64, u64)> {
v["folders"]
.as_array()
.unwrap()
.iter()
.map(|f| {
(
f["path"].as_str().unwrap().to_string(),
f["files"].as_u64().unwrap(),
f["bytes"].as_u64().unwrap(),
)
})
.collect()
}
fn names(v: &Value) -> Vec<String> {
v["files"]
.as_array()
.unwrap()
.iter()
.map(|f| f["name"].as_str().unwrap().to_string())
.collect()
}
#[test]
fn browse_lists_direct_children() {
let v = browse(&sample(), "", &Query::default());
assert_eq!(
folders(&v),
vec![("DCIM".to_string(), 3, 111), ("@carved".to_string(), 1, 7)]
);
assert_eq!(v["folders"][1]["name"], "Por assinatura");
assert_eq!(names(&v), vec!["x.txt"]);
assert_eq!(v["total_files"], 1);
}
#[test]
fn browse_inside_folder() {
let v = browse(&sample(), "DCIM", &Query::default());
assert_eq!(folders(&v), vec![("DCIM/100CANON".to_string(), 2, 101)]);
assert_eq!(v["folders"][0]["name"], "100CANON");
assert_eq!(names(&v), vec!["b.jpg"]);
let carved = browse(&sample(), "@carved", &Query::default());
assert!(folders(&carved).is_empty());
assert_eq!(names(&carved), vec!["c.jpg"]);
}
#[test]
fn browse_applies_filters() {
let q = Query {
category: Some(Category::Image),
..Query::default()
};
let v = browse(&sample(), "", &q);
assert_eq!(
folders(&v),
vec![("DCIM".to_string(), 2, 110), ("@carved".to_string(), 1, 7)]
);
assert!(names(&v).is_empty());
}
#[test]
fn prefix_is_not_parent() {
let found = vec![
Found::test_file(1, "Foto", "a.jpg", 1),
Found::test_file(2, "Fotos", "b.jpg", 1),
];
let v = browse(&found, "Foto", &Query::default());
assert_eq!(names(&v), vec!["a.jpg"]);
assert!(folders(&v).is_empty());
}
fn ids(v: Vec<&Found>) -> Vec<u64> {
v.into_iter().map(|f| f.id).collect()
}
#[test]
fn resolve_selection_folder_and_ids() {
let found = sample();
let sel = Selection {
folders: vec!["DCIM/100CANON".into()],
ids: vec![3],
exclude: vec![],
exclude_folders: vec![],
};
assert_eq!(ids(resolve_selection(&found, &sel)), vec![1, 3, 5]);
let all = Selection {
folders: vec!["".into()],
..Selection::default()
};
assert_eq!(ids(resolve_selection(&found, &all)), vec![1, 2, 3, 4, 5]);
}
#[test]
fn exclude_wins_over_ids() {
let found = sample();
let sel = Selection {
folders: vec!["DCIM".into()],
ids: vec![5],
exclude: vec![5, 2],
exclude_folders: vec![],
};
assert_eq!(ids(resolve_selection(&found, &sel)), vec![1]);
}
#[test]
fn excluded_subfolder_is_left_out() {
let found = sample();
let sel = Selection {
folders: vec!["DCIM".into()],
exclude_folders: vec!["DCIM/100CANON".into()],
..Selection::default()
};
assert_eq!(ids(resolve_selection(&found, &sel)), vec![2]);
// a folder marked again inside the excluded one comes back
let sel = Selection {
folders: vec!["".into(), "DCIM/100CANON".into()],
exclude_folders: vec!["DCIM".into()],
..Selection::default()
};
assert_eq!(ids(resolve_selection(&found, &sel)), vec![1, 3, 4, 5]);
assert_eq!(
selection_count(&found, &sel),
json!({ "files": 4, "bytes": 113 })
);
}
#[test]
fn selection_carved_folder() {
let found = sample();
let sel = Selection {
folders: vec!["@carved".into()],
..Selection::default()
};
assert_eq!(ids(resolve_selection(&found, &sel)), vec![4]);
let prefix = vec![
Found::test_file(1, "Foto", "a.jpg", 1),
Found::test_file(2, "Fotos", "b.jpg", 1),
];
let sel = Selection {
folders: vec!["Foto".into()],
..Selection::default()
};
assert_eq!(ids(resolve_selection(&prefix, &sel)), vec![1]);
}
#[test]
fn browse_paginates_files() {
let found: Vec<Found> = (0..250)
.map(|i| Found::test_file(i, "big", &format!("f{i:03}.txt"), 1))
.collect();
let q = Query {
limit: 100,
offset: 200,
..Query::default()
};
let v = browse(&found, "big", &q);
assert_eq!(v["total_files"], 250);
assert_eq!(names(&v).len(), 50);
assert_eq!(names(&v)[0], "f200.txt");
}
}
+173 -1
View File
@@ -169,6 +169,25 @@ pub fn recover_resumable(
resume: bool,
cancelled: &(dyn Fn() -> bool + Sync),
progress: &mut dyn FnMut(usize, usize, u64),
) -> Result<RecoverReport> {
recover_resumable_with(
src, files, dest, layout, None, source_key, resume, cancelled, progress,
)
}
/// [`recover_resumable`] for a folder-browsing selection: with `roots`, each
/// file lands relative to its marked folder and `layout` is ignored.
#[allow(clippy::too_many_arguments)]
pub fn recover_resumable_with(
src: &dyn Source,
files: &[&Found],
dest: &Path,
layout: RecoverLayout,
roots: Option<&SelectionRoots>,
source_key: &str,
resume: bool,
cancelled: &(dyn Fn() -> bool + Sync),
progress: &mut dyn FnMut(usize, usize, u64),
) -> Result<RecoverReport> {
use std::io::Write;
crate::owner::create_dir_all_owned(dest)?;
@@ -219,7 +238,7 @@ pub fn recover_resumable(
let _ = std::fs::remove_file(&p);
}
}
let rel = target_rel(f, layout);
let rel = target_rel_in(f, layout, roots);
let mut path = dest.join(&rel);
if let Some(parent) = path.parent() {
if let Err(e) = crate::owner::create_dir_all_owned(parent) {
@@ -292,6 +311,97 @@ pub fn recover_resumable(
Ok(report)
}
/// Marked folders of a folder-browsing recovery and the name each one gets in
/// the destination: `a/b/Projeto` is recreated as `Projeto/...`.
#[derive(Debug, Clone, Default)]
pub struct SelectionRoots {
/// `(folder path, destination name)`; a nested marked folder is dropped
/// because the outermost one already covers it.
roots: Vec<(String, String)>,
}
impl SelectionRoots {
pub fn new(folders: &[String]) -> Self {
let mut paths: Vec<String> = folders
.iter()
.map(|f| f.trim_matches('/').to_string())
.collect();
paths.sort();
paths.dedup();
let covered = |p: &str, by: &str| {
p != by
&& p != "@carved"
&& (by.is_empty() || p.strip_prefix(by).is_some_and(|r| r.starts_with('/')))
};
let kept: Vec<String> = paths
.iter()
.filter(|p| !paths.iter().any(|q| covered(p, q)))
.cloned()
.collect();
let mut used: HashSet<String> = HashSet::new();
let roots = kept
.into_iter()
.map(|path| {
let base = match path.as_str() {
"" => String::new(),
"@carved" => "Por assinatura".to_string(),
p => sanitize_name(p.rsplit('/').next().unwrap_or(p)),
};
let mut name = base.clone();
let mut n = 2;
while !base.is_empty() && !used.insert(name.clone()) {
name = format!("{base} ({n})");
n += 1;
}
(path, name)
})
.collect();
Self { roots }
}
/// Destination folder for `f`, or `None` when no marked folder holds it
/// (a file marked on its own goes to the destination root).
fn rel_dir(&self, f: &Found) -> Option<PathBuf> {
let (path, name) = self
.roots
.iter()
.find(|(path, _)| crate::explorer::in_folder(f, path))?;
let mut out = PathBuf::new();
if !name.is_empty() {
out.push(name);
}
if f.origin == Origin::Carved {
if path.is_empty() {
out.push("Por assinatura");
}
return Some(out);
}
let dir = f.dir.as_deref().unwrap_or("").trim_matches('/');
let rest = if path.is_empty() {
dir
} else {
dir[path.len()..].trim_start_matches('/')
};
for part in rest.split('/').filter(|p| !p.is_empty()) {
out.push(sanitize_name(part));
}
Some(out)
}
}
/// Destination path of `f`: relative to its marked folder when recovering a
/// selection, otherwise by `layout`.
fn target_rel_in(f: &Found, layout: RecoverLayout, roots: Option<&SelectionRoots>) -> PathBuf {
match roots {
Some(roots) => {
let mut p = roots.rel_dir(f).unwrap_or_default();
p.push(sanitize_name(&f.name));
p
}
None => target_rel(f, layout),
}
}
fn target_rel(f: &Found, layout: RecoverLayout) -> PathBuf {
let mut p = PathBuf::new();
match layout {
@@ -524,3 +634,65 @@ impl Source for FoundSource<'_> {
read_found_at(self.src, self.found, offset, buf)
}
}
#[cfg(test)]
mod selection_tests {
use super::*;
fn rel(roots: &[&str], f: &Found) -> String {
let roots = SelectionRoots::new(&roots.iter().map(|r| r.to_string()).collect::<Vec<_>>());
target_rel_in(f, RecoverLayout::Folders, Some(&roots))
.to_string_lossy()
.replace('\\', "/")
}
#[test]
fn selection_target_relative() {
let f = Found::test_file(1, "a/b/Projeto/sub", "x.jpg", 1);
assert_eq!(rel(&["a/b/Projeto"], &f), "Projeto/sub/x.jpg");
let top = Found::test_file(2, "a/b/Projeto", "y.txt", 1);
assert_eq!(rel(&["a/b/Projeto"], &top), "Projeto/y.txt");
}
#[test]
fn selection_nested_uses_outermost() {
let f = Found::test_file(1, "a/Projeto/sub", "x.jpg", 1);
assert_eq!(
rel(&["a/Projeto/sub", "a/Projeto"], &f),
"Projeto/sub/x.jpg"
);
}
#[test]
fn selection_same_name_suffix() {
let roots = ["b/Projeto", "a/Projeto"];
assert_eq!(
rel(&roots, &Found::test_file(1, "a/Projeto", "x.jpg", 1)),
"Projeto/x.jpg"
);
assert_eq!(
rel(&roots, &Found::test_file(2, "b/Projeto", "y.jpg", 1)),
"Projeto (2)/y.jpg"
);
}
#[test]
fn selection_loose_file_at_root() {
let f = Found::test_file(1, "Documentos", "solto.pdf", 1);
assert_eq!(rel(&["Outra"], &f), "solto.pdf");
assert_eq!(
rel(&["@carved"], &Found::test_carved(2, "c.jpg", 1)),
"Por assinatura/c.jpg"
);
assert_eq!(
rel(&[""], &Found::test_file(3, "a/b", "z.txt", 1)),
"a/b/z.txt"
);
}
#[test]
fn selection_target_sanitizes() {
let f = Found::test_file(1, "x/Proj:e?to/sub*", "a.jpg", 1);
assert_eq!(rel(&["x/Proj:e?to"], &f), "Proj_e_to/sub_/a.jpg");
}
}
+37 -1
View File
@@ -101,6 +101,37 @@ pub fn csv(found: &[&Found]) -> String {
out
}
/// The Guará logo, embedded so the report renders identically as a
/// standalone, offline HTML/PDF export (same reasoning as
/// `Sabiá/crates/sabia-core/src/report.rs`, which this mirrors): a
/// `src="/logo.png"` reference would 404 once the file is saved outside the
/// app's own server, and a forensic report that only half-renders without
/// network access defeats its purpose as a portable piece of evidence.
const LOGO_PNG: &[u8] = include_bytes!("../../../logo.png");
const B64: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/// Encodes the embedded logo as a `data:image/png;base64,...` URI.
fn logo_data_uri() -> String {
let mut out = String::with_capacity(LOGO_PNG.len().div_ceil(3) * 4 + 22);
out.push_str("data:image/png;base64,");
for chunk in LOGO_PNG.chunks(3) {
let b0 = chunk[0];
let b1 = chunk.get(1).copied();
let b2 = chunk.get(2).copied();
out.push(B64[(b0 >> 2) as usize] as char);
out.push(B64[(((b0 & 0b11) << 4) | (b1.unwrap_or(0) >> 4)) as usize] as char);
out.push(match b1 {
Some(b1) => B64[(((b1 & 0b1111) << 2) | (b2.unwrap_or(0) >> 6)) as usize] as char,
None => '=',
});
out.push(match b2 {
Some(b2) => B64[(b2 & 0b111111) as usize] as char,
None => '=',
});
}
out
}
fn esc(s: &str) -> String {
s.replace('&', "&amp;")
.replace('<', "&lt;")
@@ -135,6 +166,9 @@ pub fn html(r: &ReportInput) -> String {
r#"<!doctype html><html lang="pt-BR"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Guará: relatório de recuperação</title><style>
:root{color-scheme:light}*{box-sizing:border-box}body{margin:0;font:14px/1.5 -apple-system,"Segoe UI",Inter,Roboto,sans-serif;color:#10201f;background:#f3f7f7}
main{max-width:1100px;margin:0 auto;padding:36px 28px 60px}header{border-bottom:3px solid #0f766e;padding-bottom:14px;margin-bottom:22px}
.brand{display:flex;align-items:center;gap:10px}.brand img{width:30px;height:30px;object-fit:contain}
.badges{display:flex;gap:6px;margin-top:8px}.badge{font:700 11px ui-monospace,Menlo,Consolas,monospace;letter-spacing:.08em;text-transform:uppercase;padding:2px 8px;border-radius:3px;border:1px solid #0f766e;color:#0f766e;background:#e7f3f2}
.badge-tlp{color:#8a5a00;border-color:#8a5a00;background:#fff0cf}
h1{margin:0;font-size:28px;letter-spacing:-.02em}h2{margin:30px 0 10px;font-size:17px;color:#0f766e}small,.mut{color:#5b6f6d}
table{width:100%;border-collapse:collapse;background:#fff;border-radius:10px;overflow:hidden;box-shadow:0 1px 3px rgba(0,0,0,.08)}
th,td{padding:7px 10px;text-align:left;border-bottom:1px solid #e4eded;vertical-align:top;font-size:13px}th{background:#e7f3f2;color:#0b4f4a;font-weight:600}
@@ -145,7 +179,9 @@ td.n{text-align:right;font-variant-numeric:tabular-nums}.mono{font-family:ui-mon
footer{margin-top:34px;color:#5b6f6d;font-size:12px}@media print{body{background:#fff}main{padding:0}table{box-shadow:none}h2{break-after:avoid}tr{break-inside:avoid}}
</style></head><body><main>"#,
);
o.push_str("<header><h1>Relatório de recuperação de arquivos</h1><div class=\"mut\">Gerado pelo Guará ");
o.push_str("<header><div class=\"brand\"><img src=\"");
o.push_str(&logo_data_uri());
o.push_str("\" alt=\"\"><h1>Relatório de recuperação de arquivos</h1></div><div class=\"badges\"><span class=\"badge badge-tlp\">TLP:AMBER</span><span class=\"badge\">Uso autorizado</span></div><div class=\"mut\">Gerado pelo Guará ");
o.push_str(env!("CARGO_PKG_VERSION"));
o.push_str(&format!(" em {}</div></header>", fmt_unix(now)));
+12 -2
View File
@@ -235,7 +235,12 @@ pub fn run(
return Outcome::Interrupted(cp);
}
}
handler.rebuild_pending();
if !handler.rebuild_pending(cancelled) {
// Paused/stopped during reassembly: the truncated candidates were already reported,
// and on resume (all ranges done) the scan finishes without redoing them.
cp.next_id = next_id.load(std::sync::atomic::Ordering::Relaxed);
return Outcome::Interrupted(cp);
}
Outcome::Completed
}
@@ -306,9 +311,13 @@ impl Handler<'_> {
self.sink.replace(f);
}
fn rebuild_pending(&mut self) {
/// Reassembles queued fragmented files. Returns `false` if cancelled part-way.
fn rebuild_pending(&mut self, cancelled: &(dyn Fn() -> bool + Sync)) -> bool {
let pend = std::mem::take(&mut self.pending);
for p in pend {
if cancelled() {
return false;
}
let off = p.found.first_offset().unwrap_or(0);
if p.mp4 {
self.rebuild_mp4(p, off);
@@ -339,6 +348,7 @@ impl Handler<'_> {
self.sink.replace(f);
}
}
true
}
}
+121 -2
View File
@@ -336,6 +336,7 @@ impl Engine {
"error": s.error,
"report": s.report,
"elapsed": elapsed,
"stopping": s.status == Status::Running && j.cancelled(),
"source": j.source().is_some(),
"source_path": j.src_path.lock().unwrap().clone(),
"session_file": j.session_file.lock().unwrap().as_ref().map(|p| p.to_string_lossy().to_string()),
@@ -359,6 +360,13 @@ impl Engine {
Ok(json!({ "total": total, "items": page }))
}
/// One level of the folder tree (see [`crate::explorer::browse`]).
pub fn browse(&self, id: &str, path: &str, q: &Query) -> Result<Value> {
let j = self.job(id)?;
let s = j.st.lock().unwrap();
Ok(crate::explorer::browse(&s.found, path, q))
}
/// Sidebar navigation facet counts (categories, dates, folders, cameras).
pub fn facets(&self, id: &str) -> Result<Value> {
let j = self.job(id)?;
@@ -463,6 +471,7 @@ impl Engine {
scan_id: &str,
ids: Option<Vec<u64>>,
filter: Option<Query>,
selection: Option<crate::explorer::Selection>,
dest: &str,
layout: recover::RecoverLayout,
) -> Result<String> {
@@ -470,6 +479,12 @@ impl Engine {
let src = sj.source().ok_or_else(no_source)?;
let files: Vec<Found> = {
let s = sj.st.lock().unwrap();
if let Some(sel) = &selection {
crate::explorer::resolve_selection(&s.found, sel)
.into_iter()
.cloned()
.collect()
} else {
match (&ids, &filter) {
(Some(ids), _) => ids
.iter()
@@ -478,7 +493,11 @@ impl Engine {
(None, Some(q)) => q.select(&s.found).into_iter().cloned().collect(),
(None, None) => s.found.clone(),
}
}
};
let roots = selection
.as_ref()
.map(|sel| recover::SelectionRoots::new(&sel.folders));
if files.is_empty() {
return Err(Error::msg("nenhum arquivo selecionado"));
}
@@ -526,11 +545,12 @@ impl Engine {
};
};
let refs: Vec<&Found> = files.iter().collect();
let res = recover::recover_resumable(
let res = recover::recover_resumable_with(
src.as_ref(),
&refs,
&dest_path,
layout,
roots.as_ref(),
&source_key,
true,
&cancelled,
@@ -1079,11 +1099,78 @@ impl Engine {
"só sessões automáticas podem ser apagadas por aqui",
));
}
let running = self.jobs.lock().unwrap().values().any(|j| {
j.session_file.lock().unwrap().as_deref() == Some(p)
&& j.st.lock().unwrap().status == Status::Running
});
if running {
return Err(Error::msg(
"esta varredura ainda está em andamento; pause ou pare antes de apagar a sessão",
));
}
let _ = std::fs::remove_file(p.with_extension("meta.json"));
std::fs::remove_file(p)?;
Ok(())
}
/// `true` if an open job (scanning, paused, or loaded) still autosaves to this file.
fn session_in_use(&self, p: &Path) -> bool {
self.jobs
.lock()
.unwrap()
.values()
.any(|j| j.session_file.lock().unwrap().as_deref() == Some(p))
}
/// Deletes autosaved sessions older than `days` (`None` = the configured retention;
/// `Some(0)` = all of them). Sessions held by open jobs are always kept.
/// Returns how many were removed.
pub fn sessions_prune(&self, days: Option<u32>) -> usize {
let days = match days {
Some(d) => d,
None => match crate::settings::load().session_retention_days {
0 => return 0, // retention disabled: keep everything
d => d,
},
};
let dir = sessions_dir();
let now = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|d| d.as_secs() as i64)
.unwrap_or(0);
let cutoff = now - days as i64 * 86_400;
let mut removed = 0;
let Ok(rd) = std::fs::read_dir(&dir) else {
return 0;
};
for e in rd.flatten() {
let path = e.path();
let name = e.file_name().to_string_lossy().to_string();
if !name.ends_with(".json") || name.ends_with(".meta.json") {
continue;
}
let saved_at = std::fs::read(path.with_extension("meta.json"))
.ok()
.and_then(|b| serde_json::from_slice::<Value>(&b).ok())
.and_then(|v| v["saved_at"].as_i64())
.or_else(|| {
e.metadata()
.and_then(|m| m.modified())
.ok()
.and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok())
.map(|d| d.as_secs() as i64)
})
.unwrap_or(now);
if saved_at <= cutoff && !self.session_in_use(&path) {
let _ = std::fs::remove_file(path.with_extension("meta.json"));
if std::fs::remove_file(&path).is_ok() {
removed += 1;
}
}
}
removed
}
// ---------------------------------------------------------------- RPC
pub fn rpc(&self, method: &str, p: Value) -> Result<Value> {
@@ -1232,6 +1319,28 @@ impl Engine {
.and_then(|v| v.as_u64())
.ok_or_else(|| Error::msg("id ausente"))?
)?),
"browse" => {
let q: Query = p
.get("query")
.cloned()
.filter(|v| !v.is_null())
.map(serde_json::from_value)
.transpose()?
.unwrap_or_default();
let path = p.get("path").and_then(|v| v.as_str()).unwrap_or("");
self.browse(&s("job")?, path, &q)?
}
"selection_count" => {
let sel: crate::explorer::Selection = p
.get("selection")
.cloned()
.map(serde_json::from_value)
.transpose()?
.unwrap_or_default();
let j = self.job(&s("job")?)?;
let st = j.st.lock().unwrap();
crate::explorer::selection_count(&st.found, &sel)
}
"results" => {
let q: Query = p
.get("query")
@@ -1265,7 +1374,13 @@ impl Engine {
.and_then(|v| v.as_str())
.and_then(recover::RecoverLayout::parse)
.unwrap_or_default();
json!({ "job": self.start_recover(&s("job")?, ids, filter, &s("dest")?, layout)? })
let selection: Option<crate::explorer::Selection> = p
.get("selection")
.cloned()
.filter(|v| !v.is_null())
.map(serde_json::from_value)
.transpose()?;
json!({ "job": self.start_recover(&s("job")?, ids, filter, selection, &s("dest")?, layout)? })
}
"image_start" => {
let format: image::ImageFormat = p
@@ -1295,6 +1410,10 @@ impl Engine {
self.session_delete(&s("path")?)?;
json!({})
}
"sessions_prune" => {
let all = p.get("all").and_then(|v| v.as_bool()) == Some(true);
json!({ "removed": self.sessions_prune(if all { Some(0) } else { None }) })
}
"session_load" => json!({ "job": self.load_session(&s("path")?)? }),
"defaults" => {
let home = crate::owner::user_home().to_string_lossy().to_string();
+4
View File
@@ -27,6 +27,9 @@ pub struct Settings {
/// without sending any telemetry).
#[serde(default = "yes")]
pub updates: bool,
/// Autosaved sessions older than this many days are deleted on startup (`0` = keep forever).
#[serde(default)]
pub session_retention_days: u32,
}
fn auto() -> String {
@@ -46,6 +49,7 @@ impl Default for Settings {
notify: true,
maps: false,
updates: true,
session_retention_days: 0,
}
}
}
+37
View File
@@ -510,3 +510,40 @@ impl Default for ScanOptions {
}
}
}
#[cfg(test)]
impl Found {
/// Minimal resident file for unit tests: `dir` `""` means the volume root.
pub(crate) fn test_file(id: u64, dir: &str, name: &str, size: u64) -> Self {
let ext = name.rsplit('.').next().unwrap_or("").to_lowercase();
Found {
id,
name: name.into(),
dir: Some(dir.into()),
category: crate::signatures::category_for_ext(&ext),
ext,
size,
origin: Origin::Fat,
confidence: Confidence::High,
data: DataLoc::Resident { bytes: Vec::new() },
modified: None,
created: None,
accessed: None,
taken: None,
camera: None,
px: None,
gps: false,
sig: None,
note: None,
}
}
/// The same, found by signature (no folder).
pub(crate) fn test_carved(id: u64, name: &str, size: u64) -> Self {
Found {
dir: None,
origin: Origin::Carved,
..Self::test_file(id, "", name, size)
}
}
}
+24 -5
View File
@@ -29,6 +29,8 @@ struct Release {
struct Asset {
name: String,
browser_download_url: String,
#[serde(default)]
size: u64,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
@@ -52,13 +54,25 @@ fn curl_text(url: &str) -> Result<String> {
Ok(String::from_utf8_lossy(&out.stdout).into_owned())
}
fn curl_download(url: &str, dest: &Path) -> Result<()> {
let status = Command::new("curl")
/// Downloads `url` to `dest`, polling the file size to report `percent` (0-100) through
/// `on_pct` while curl runs (no stderr parsing; `total` comes from the release asset size).
fn curl_download(url: &str, dest: &Path, total: u64, on_pct: &dyn Fn(u8)) -> Result<()> {
let mut child = Command::new("curl")
.args(["-fsSL", "-H", "User-Agent: guara-updater", "-o"])
.arg(dest)
.arg(url)
.status()
.spawn()
.map_err(|e| Error::msg(format!("curl {url}: {e}")))?;
let status = loop {
if let Some(st) = child.try_wait().map_err(|e| Error::msg(e.to_string()))? {
break st;
}
let got = fs::metadata(dest).map(|m| m.len()).unwrap_or(0);
if let Some(pct) = got.saturating_mul(100).checked_div(total) {
on_pct(pct.min(100) as u8);
}
std::thread::sleep(std::time::Duration::from_millis(150));
};
if !status.success() {
return Err(Error::msg(format!("curl {url}: download falhou")));
}
@@ -145,7 +159,7 @@ pub fn apply(current_exe: &PathBuf) -> Result<String> {
let tmp_dir = std::env::temp_dir().join("guara-update");
fs::create_dir_all(&tmp_dir)?;
let archive_path = tmp_dir.join(&asset.name);
curl_download(&asset.browser_download_url, &archive_path)?;
curl_download(&asset.browser_download_url, &archive_path, 0, &|_| {})?;
if let Some(checksum_asset) = checksum_asset {
let expected = curl_text(&checksum_asset.browser_download_url)?;
@@ -350,7 +364,12 @@ where
let download_path = tmp_dir.join(&asset.name);
on_progress("downloading");
curl_download(&asset.browser_download_url, &download_path)?;
curl_download(
&asset.browser_download_url,
&download_path,
asset.size,
&|pct| on_progress(&format!("downloading:{pct}")),
)?;
if let Some(checksum_asset) = checksum_asset {
on_progress("verifying");
+122
View File
@@ -381,6 +381,7 @@ fn sessao_da_v0_1_0_abre_e_funciona() {
&job,
None,
Some(service::Query::default()),
None,
out.path().to_str().unwrap(),
recover::RecoverLayout::Folders,
)
@@ -437,6 +438,7 @@ fn sessao_abre_sem_a_origem_e_pode_ser_reconectada() {
&job,
None,
None,
None,
out.path().to_str().unwrap(),
recover::RecoverLayout::Folders,
)
@@ -452,6 +454,7 @@ fn sessao_abre_sem_a_origem_e_pode_ser_reconectada() {
&job,
None,
None,
None,
out.path().to_str().unwrap(),
recover::RecoverLayout::Folders,
)
@@ -712,6 +715,7 @@ fn espaco_insuficiente_no_destino_e_avisado_antes_de_copiar() {
&job,
None,
None,
None,
out.path().to_str().unwrap(),
recover::RecoverLayout::Folders,
)
@@ -719,3 +723,121 @@ fn espaco_insuficiente_no_destino_e_avisado_antes_de_copiar() {
assert!(e.to_string().contains("Espaço insuficiente"), "{e}");
assert!(recover::free_space(out.path()).unwrap_or(0) > 0);
}
/// Folder browsing on FAT32 (deleted short names lose their first character,
/// hence `_raia.jpg`): one level at a time, and recovering a marked folder
/// recreates only that folder (plus single marked files at the root, minus the
/// unmarked ones).
#[test]
fn navegacao_por_pastas_e_recuperacao_da_selecao() {
init();
let Some(dir) = fixtures() else { return };
let img = dir.join("fat32.img");
let eng = service::Engine::new();
let job = eng
.start_scan(img.to_str().unwrap(), ScanOptions::default())
.unwrap();
wait_done(&eng, &job);
let root = eng.browse(&job, "", &service::Query::default()).unwrap();
let folders: Vec<(String, u64)> = root["folders"]
.as_array()
.unwrap()
.iter()
.filter(|f| f["path"] != "@carved")
.map(|f| {
(
f["path"].as_str().unwrap().to_string(),
f["files"].as_u64().unwrap(),
)
})
.collect();
assert!(folders.contains(&("Documentos".into(), 5)), "{folders:?}");
assert!(folders.contains(&("Fotos".into(), 2)), "{folders:?}");
let docs = eng
.browse(&job, "Documentos", &service::Query::default())
.unwrap();
assert_eq!(docs["folders"][0]["path"], "Documentos/Trabalho");
assert_eq!(docs["folders"][0]["files"], 3);
let all = eng
.results(
&job,
&service::Query {
limit: 5000,
..Default::default()
},
)
.unwrap();
let id_of = |name: &str| {
all["items"]
.as_array()
.unwrap()
.iter()
.find(|i| i["name"] == name && i["origin"] == "fat")
.unwrap_or_else(|| panic!("{name} not found"))["id"]
.as_u64()
.unwrap()
};
let selection = explorer::Selection {
folders: vec!["Documentos/Trabalho".into()],
ids: vec![id_of("_raia.jpg")],
exclude: vec![id_of("tese.docx")],
exclude_folders: vec![],
};
let out = tempfile::tempdir().unwrap();
let rj = eng
.start_recover(
&job,
None,
None,
Some(selection),
out.path().to_str().unwrap(),
recover::RecoverLayout::Folders,
)
.unwrap();
wait_done(&eng, &rj);
let got = hashes_in(out.path());
let mut paths: Vec<String> = got
.values()
.map(|p| {
p.strip_prefix(out.path())
.unwrap()
.to_string_lossy()
.replace('\\', "/")
})
.collect();
paths.sort();
assert_eq!(
paths,
vec!["Trabalho/_otas.txt", "Trabalho/relatorio.pdf", "_raia.jpg"]
);
let expected = expected(&dir, "fat32");
for (hash, original) in &expected {
let wanted = [
"Documentos/Trabalho/notas.txt",
"Documentos/Trabalho/relatorio.pdf",
"Fotos/praia.jpg",
];
if wanted.contains(&original.as_str()) {
assert!(got.contains_key(hash), "content of {original} differs");
}
}
assert!(out.path().join("guara-manifesto.json").is_file());
let empty = explorer::Selection {
folders: vec!["Nada/Aqui".into()],
..Default::default()
};
let e = eng
.start_recover(
&job,
None,
None,
Some(empty),
out.path().to_str().unwrap(),
recover::RecoverLayout::Folders,
)
.unwrap_err();
assert!(e.to_string().contains("nenhum arquivo selecionado"), "{e}");
}
+1
View File
@@ -143,6 +143,7 @@ fn configuracoes_antigas_ganham_os_valores_padrao_novos() {
notify: false,
maps: true,
updates: false,
..Default::default()
})
.unwrap();
let s = settings::load();
Binary file not shown.

Before

Width:  |  Height:  |  Size: 672 KiB

After

Width:  |  Height:  |  Size: 693 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 679 KiB

After

Width:  |  Height:  |  Size: 700 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 KiB

After

Width:  |  Height:  |  Size: 698 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 683 KiB

After

Width:  |  Height:  |  Size: 706 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

+16 -2
View File
@@ -11,12 +11,22 @@ Guará has a desktop app (Tauri) and the same front end in the browser with `gua
After a scan, results open in a file-manager style explorer built for thousands of items:
- **Left:** navigation by type, real photo date (EXIF, by year and month), folder, camera, confidence and GPS, with an option to hide small files and duplicates.
- **Center:** thumbnail grid or list, grouped by day or month, with virtual scrolling. A filter chip shows what is active and clears it in one click.
- **Center:** thumbnail grid or list, grouped by day or month, with virtual scrolling, or the **Folders** view (below) to browse one folder at a time. A filter chip shows what is active and clears it in one click.
- **Right:** details panel with the preview, folder, dates (taken, modified, created, accessed), camera, resolution and the file metadata. The badge shows the **confidence** of the file (high, medium or low).
- **Bottom bar:** selection count and the recovery buttons. Recovery always goes to another folder and writes a manifest with MD5, SHA-1 and SHA-256.
Arrow keys move through the files, and Space opens the full-screen quick look. Selection works like Finder or Explorer (Ctrl, Shift, keyboard).
### Browsing by folder
<p align="center"><img src="img/folders-light-en.png" width="900" alt="The Folders view: the root of the recovered files with DCIM ticked, Viagens partly ticked, the selection total at the bottom and the folder details on the right"></p>
The third view button (the folder icon, next to grid and list) turns the explorer into a file manager over what was found. The center shows **one folder at a time**: its subfolders first, each with how many files and how much space it holds counting everything below it, then the files directly inside. A breadcrumb at the top (`Root › Documents › Project`) goes back up; double-click or Enter opens a folder, Backspace or Alt+↑ goes up, and clicking a folder in the sidebar tree jumps to it. Files found only by signature, which have no known folder, sit in **By signature** at the root. Filters (type, date, confidence…) still apply and change the counts.
To recover, tick folders and files with their boxes; the selection survives navigation. Ticking a folder takes **everything inside it**, at any depth, even what the active filters hide. Unticking a subfolder or a file inside a ticked folder leaves the folder half-ticked and keeps that item out. The bottom bar shows the exact total, and **Recover selection** recreates each ticked folder in the destination **from itself down**: recovering `Documents/Clients/Project` writes `Project/...` with all its subfolders. Files ticked on their own go to the root of the destination, and two ticked folders with the same name become `Project` and `Project (2)`. The manifest with MD5, SHA-1 and SHA-256 is written as always.
Only folders that hold at least one recovered file appear: Guará knows folders through the paths of the files it finds.
## Themes
The switch at the bottom of the sidebar offers **Auto** (follows the system), **Light** and **Dark**. The choice is saved.
@@ -27,9 +37,13 @@ The switch at the bottom of the sidebar offers **Auto** (follows the system), **
**Settings** (the gear at the bottom of the sidebar) has a **Language** selector: **Auto** follows the system language, or you can pick **Português** or **English**. The change applies right away. The same dialog controls automatic updates (below), notifications for long tasks and online maps for photos with GPS (off by default, because it downloads OpenStreetMap tiles).
## Saved sessions
Sessions are autosaved and listed under **Recent** in the sidebar. Hover one and click the ✕ to delete it, or use the trash button in the section title to delete them all; sessions open in the app are kept. **Settings > Delete autosaved sessions after** removes old ones on startup (never by default; 7, 30 or 90 days).
## Updates
When the desktop app opens it asks Gitea for the latest release. If a newer version exists, a card appears at the bottom right with the versions and the release address. For the CLI, `guara update` checks for and installs updates with SHA-256 verification. **Settings > Automatic updates** turns the startup check off and has a **Check now** button. The check sends nothing besides what any browser sends to Gitea. `guara ui` in the browser does not update itself.
When the desktop app opens it asks Gitea for the latest release. If a newer version exists, a card appears at the bottom right with the versions and the release address. For the CLI, `guara update` checks for and installs updates with SHA-256 verification. **Settings > Automatic updates** turns the startup check off and has a **Check now** button. Clicking **Update now** shows a progress bar with the download percentage, then the verify, install and restart steps; the app stays responsive meanwhile. The check sends nothing besides what any browser sends to Gitea. `guara ui` in the browser does not update itself.
<p align="center"><img src="img/settings-language-en.png" width="420" alt="The Settings dialog with the Language selector set to English"></p>
+16 -2
View File
@@ -11,12 +11,22 @@ O Guará tem um app desktop (Tauri) e o mesmo front-end no navegador com `guara
Depois da varredura, os resultados abrem num explorador no estilo de um gerenciador de arquivos, pensado para milhares de itens:
- **Esquerda:** navegação por tipo, data real da foto (EXIF, por ano e mês), pasta, câmera, confiança e GPS, com opção de ocultar arquivos pequenos e duplicadas.
- **Centro:** grade de miniaturas ou lista, agrupadas por dia ou mês, com rolagem virtual. Uma etiqueta mostra o filtro ativo e o remove com um clique.
- **Centro:** grade de miniaturas ou lista, agrupadas por dia ou mês, com rolagem virtual, ou a visualização **Pastas** (abaixo) para navegar uma pasta por vez. Uma etiqueta mostra o filtro ativo e o remove com um clique.
- **Direita:** painel de detalhes com a pré-visualização, pasta, datas (tirada, modificada, criada, acessada), câmera, resolução e os metadados do arquivo. O selo mostra a **confiança** do arquivo (alta, média ou baixa).
- **Barra inferior:** quantidade selecionada e os botões de recuperação. A recuperação sempre vai para outra pasta e grava um manifesto com MD5, SHA-1 e SHA-256.
As setas navegam pelos arquivos e a barra de espaço abre a visualização rápida em tela cheia. A seleção funciona como no Finder ou no Explorer (Ctrl, Shift e teclado).
### Navegando por pastas
<p align="center"><img src="../img/folders-light-pt.png" width="900" alt="A visualização Pastas: a raiz dos arquivos encontrados com DCIM marcada, Viagens parcialmente marcada, o total da seleção embaixo e os detalhes da pasta à direita"></p>
O terceiro botão de visualização (o ícone de pasta, ao lado de grade e lista) transforma o explorador num gerenciador de arquivos sobre o que foi encontrado. O centro mostra **uma pasta por vez**: primeiro as subpastas, cada uma com quantos arquivos e quanto espaço contém somando tudo abaixo dela, depois os arquivos que estão diretamente nela. Um caminho no topo (`Raiz › Documentos › Projeto`) volta para cima; duplo clique ou Enter abre uma pasta, Backspace ou Alt+↑ sobe, e clicar numa pasta da árvore lateral vai direto até ela. Arquivos achados só por assinatura, que não têm pasta conhecida, ficam em **Por assinatura** na raiz. Os filtros (tipo, data, confiança…) continuam valendo e mudam as contagens.
Para recuperar, marque pastas e arquivos pelas caixas; a seleção continua ao navegar. Marcar uma pasta leva **tudo o que está dentro dela**, em qualquer profundidade, inclusive o que os filtros ativos escondem. Desmarcar uma subpasta ou um arquivo dentro de uma pasta marcada deixa a pasta parcialmente marcada e mantém aquele item de fora. A barra de baixo mostra o total exato, e **Recuperar seleção** recria cada pasta marcada no destino **a partir dela mesma**: recuperar `Documentos/Clientes/Projeto` grava `Projeto/...` com todas as subpastas. Arquivos marcados soltos vão para a raiz do destino, e duas pastas marcadas com o mesmo nome viram `Projeto` e `Projeto (2)`. O manifesto com MD5, SHA-1 e SHA-256 é gravado como sempre.
Só aparecem pastas que contêm pelo menos um arquivo recuperado: o Guará conhece as pastas pelos caminhos dos arquivos que encontra.
## Temas
O seletor no fim da barra lateral oferece **Auto** (acompanha o sistema), **Claro** e **Escuro**. A escolha fica salva.
@@ -27,9 +37,13 @@ O seletor no fim da barra lateral oferece **Auto** (acompanha o sistema), **Clar
Em **Configurações** (a engrenagem no fim da barra lateral) há o seletor **Idioma**: **Auto** acompanha o idioma do sistema, ou você escolhe **Português** ou **English**. A troca vale na hora. A mesma janela controla as atualizações automáticas (abaixo), as notificações de tarefas longas e os mapas online das fotos com GPS (desligados por padrão, porque baixam blocos do OpenStreetMap).
## Sessões salvas
As sessões são salvas sozinhas e listadas em **Recentes** na barra lateral. Passe o mouse sobre uma e clique no ✕ para apagá-la, ou use o botão de lixeira no título da seção para apagar todas; sessões abertas no app são mantidas. **Configurações > Apagar sessões salvas sozinhas após** remove as antigas ao abrir (nunca, por padrão; 7, 30 ou 90 dias).
## Atualizações
Ao abrir, o app desktop consulta o Gitea para verificar se há uma versão mais nova. Havendo versão nova, aparece um cartão no canto inferior direito com as versões e o endereço da release. Para o CLI, `guara update` verifica e instala atualizações com conferência de SHA-256. **Configurações > Atualizações automáticas** desliga a verificação ao abrir e tem o botão **Verificar agora**. A consulta não envia nada além do que qualquer navegador envia ao Gitea. O `guara ui` no navegador não se atualiza sozinho.
Ao abrir, o app desktop consulta o Gitea para verificar se há uma versão mais nova. Havendo versão nova, aparece um cartão no canto inferior direito com as versões e o endereço da release. Para o CLI, `guara update` verifica e instala atualizações com conferência de SHA-256. **Configurações > Atualizações automáticas** desliga a verificação ao abrir e tem o botão **Verificar agora**. Ao clicar em **Atualizar agora**, aparece uma barra de progresso com a porcentagem do download e depois as etapas de verificação, instalação e reinício; o app continua responsivo. A consulta não envia nada além do que qualquer navegador envia ao Gitea. O `guara ui` no navegador não se atualiza sozinho.
<p align="center"><img src="../img/settings-language-pt.png" width="420" alt="A janela de Configurações com o seletor de Idioma"></p>