atualiza versão para 0.0.4; corrige contador de arquivos no progresso do backup e exibição da última versão na aba Sobre

This commit is contained in:
Alexander Sabino 2026-05-09 11:04:42 +01:00
parent 990b0dea4d
commit 971293cacf
6 changed files with 46 additions and 31 deletions

View File

@ -22,7 +22,13 @@ Versão atual: **0.0.2**
---
## <20> Changelog
## <20> Changelog### [0.0.4] — Correções de bugs
#### Corrigido
- **Progresso do backup:** contador de arquivos processados ultrapassava o total porque `find -type f` contava apenas arquivos regulares, enquanto o `tar -v` emite uma linha por entrada (incluindo diretórios e symlinks). Corrigido removendo `-type f` do comando `find`.
- **Aba Sobre — última versão:** a verificação da versão mais recente era feita no browser, falhando dentro do Docker por restrições de rede/CORS. A requisição foi movida para o backend, que lê o `package.json` diretamente do repositório via `raw.githubusercontent.com`.
---
### [0.0.3] — Settings, About, i18n e autenticação
#### Adicionado

View File

@ -1,6 +1,6 @@
{
"name": "dockerbackup-app",
"version": "0.0.3",
"version": "0.0.4",
"description": "Aplicacao web para backup e restauracao de volumes Docker",
"main": "src/server.js",
"scripts": {

View File

@ -1416,42 +1416,30 @@ async function loadAboutView() {
const updateStatus = document.querySelector('#aboutUpdateStatus');
const updateBtn = document.querySelector('#aboutUpdateBtn');
if (latestVerEl) latestVerEl.textContent = t('about.checking');
try {
const about = await api('/api/about');
const current = about.currentVersion || '—';
const latest = about.latestVersion || null;
if (currentVerEl) currentVerEl.textContent = current;
if (latestVerEl) latestVerEl.textContent = latest || '—';
// Fetch latest from GitHub
if (latestVerEl) latestVerEl.textContent = t('about.checking');
try {
const ghRes = await fetch('https://api.github.com/repos/asabino2/dockerbackup/tags', {
headers: { Accept: 'application/vnd.github.v3+json' },
});
if (ghRes.ok) {
const tags = await ghRes.json();
const latestTag = tags[0]?.name?.replace(/^v/, '') || null;
if (latestVerEl) latestVerEl.textContent = latestTag || '—';
if (updateWrap) updateWrap.classList.remove('hidden');
if (latestTag && current !== latestTag) {
if (updateStatus) updateStatus.textContent = t('about.updateAvailable');
if (updateBtn) updateBtn.classList.remove('hidden');
} else {
if (updateStatus) updateStatus.textContent = t('about.upToDate');
if (updateBtn) updateBtn.classList.add('hidden');
}
} else {
if (latestVerEl) latestVerEl.textContent = '—';
if (updateStatus) updateStatus.textContent = t('about.checkError');
if (updateWrap) updateWrap.classList.remove('hidden');
}
} catch {
if (latestVerEl) latestVerEl.textContent = '—';
if (updateWrap) updateWrap.classList.remove('hidden');
if (latest && current !== latest) {
if (updateStatus) updateStatus.textContent = t('about.updateAvailable');
if (updateBtn) updateBtn.classList.remove('hidden');
} else if (latest) {
if (updateStatus) updateStatus.textContent = t('about.upToDate');
if (updateBtn) updateBtn.classList.add('hidden');
} else {
if (updateStatus) updateStatus.textContent = t('about.checkError');
if (updateWrap) updateWrap.classList.remove('hidden');
if (updateBtn) updateBtn.classList.add('hidden');
}
} catch (error) {
if (currentVerEl) currentVerEl.textContent = '—';
if (latestVerEl) latestVerEl.textContent = '—';
showToast(error.message, true);
}
}

View File

@ -282,6 +282,11 @@
<div class="about-changelog">
<h3 data-i18n="about.changelog">Últimas alterações</h3>
<div id="aboutChangelog" class="changelog-content">
<h4>0.0.4</h4>
<ul>
<li>Correção: contador de arquivos no progresso do backup ultrapassava o total</li>
<li>Correção: aba Sobre não exibia a última versão disponível</li>
</ul>
<h4>0.0.3</h4>
<ul>
<li>Suporte a múltiplos idiomas (10 idiomas)</li>

View File

@ -408,7 +408,7 @@ class BackupService {
if (backupScope === 'volumes') {
pushLog('Contando arquivos para barra de progresso.', 'contando');
const countCmd = `set -eu; TOTAL=0; for p in ${relSourcePaths.map((item) => shellQuote(item)).join(' ')}; do if [ -e \"/$p\" ]; then C=$(find \"/$p\" -type f 2>/dev/null | wc -l | tr -d \" \" ); TOTAL=$((TOTAL + C)); fi; done; echo \"$TOTAL\"`;
const countCmd = `set -eu; TOTAL=0; for p in ${relSourcePaths.map((item) => shellQuote(item)).join(' ')}; do if [ -e \"/$p\" ]; then C=$(find \"/$p\" 2>/dev/null | wc -l | tr -d \" \" ); TOTAL=$((TOTAL + C)); fi; done; echo \"$TOTAL\"`;
const output = await this.dockerService.runContainerCommand(containerId, countCmd);
const parsed = Number(output.split(/\r?\n/).pop());
fileTotal = Number.isFinite(parsed) ? parsed : 0;

View File

@ -138,7 +138,23 @@ async function main() {
const pkgPath = path.join(process.cwd(), 'package.json');
const pkgRaw = await fs.readFile(pkgPath, 'utf8');
const pkg = JSON.parse(pkgRaw);
response.json({ currentVersion: pkg.version, name: pkg.name || 'dockerbackup' });
const currentVersion = pkg.version;
let latestVersion = null;
try {
const ghRes = await fetch('https://raw.githubusercontent.com/asabino2/dockerbackup/main/package.json', {
headers: { 'User-Agent': 'dockerbackup-app' },
signal: AbortSignal.timeout(8000),
});
if (ghRes.ok) {
const remotePkg = await ghRes.json();
if (remotePkg.version) latestVersion = String(remotePkg.version);
}
} catch {
// Non-fatal: latestVersion stays null
}
response.json({ currentVersion, latestVersion, name: pkg.name || 'dockerbackup' });
} catch (error) {
response.status(500).json({ error: error.message });
}