diff --git a/app.py b/app.py index 75f3bce..09c622c 100644 --- a/app.py +++ b/app.py @@ -549,6 +549,13 @@ def run_backup(): except Exception as e: return jsonify({"error": str(e), "trace": traceback.format_exc()}), 500 +@app.route("/api/download/") +def download_file(filename): + path = f"/tmp/restore-temp/{filename}" + if os.path.exists(path): + return send_file(path, as_attachment=True) + return "File not found locally", 404 + # ────────────────────────────────────────────── # STATIC & LOGS # ────────────────────────────────────────────── diff --git a/static/index.html b/static/index.html index d5b8bbe..b9ecfdd 100644 --- a/static/index.html +++ b/static/index.html @@ -221,6 +221,7 @@ input,button,select{font-family:inherit} @@ -504,6 +505,7 @@ function openRestoreModal(type, filename, size) {
`; document.getElementById('modal-confirm').style.display = 'inline-block'; + document.getElementById('modal-download').style.display = 'none'; document.getElementById('restore-modal').classList.add('show'); // Start download @@ -542,6 +544,8 @@ function openRestoreModal(type, filename, size) { ` cp -r ${d.extracted_to}/* /var/lib/docker/volumes/yccsckck4g004gosccwc4kg4_gitea-data/_data/`; } document.getElementById('restore-instructions').value = instructions || 'Pronto para uso.'; + document.getElementById('modal-download').href = `/api/download/${filename}`; + document.getElementById('modal-download').style.display = 'inline-block'; } else { document.getElementById('restore-instructions').value = `Erro: ${d.error}`; } @@ -569,6 +573,7 @@ function openRestoreRepo(owner, repoName, size) { `; + document.getElementById('modal-download').style.display = 'none'; document.getElementById('restore-modal').classList.add('show'); fetch(`${API}/restore/repo`, { @@ -588,6 +593,9 @@ function openRestoreRepo(owner, repoName, size) { ` cp -r ${d.extracted_to}/* /var/lib/docker/volumes/yccsckck4g004gosccwc4kg4_gitea-data/_data/git/repositories/${owner}/\n` + ` # Reinicie o Gitea\n` + ` docker start `; + + document.getElementById('modal-download').href = `/api/download/${repoName}`; + document.getElementById('modal-download').style.display = 'inline-block'; } else { document.getElementById('restore-instructions').value = `Erro: ${d.error}`; }