From e7bbd080b0b82ab033882b212489d22cab46cc4e Mon Sep 17 00:00:00 2001 From: Roby Date: Tue, 3 Nov 2026 20:02:33 +0100 Subject: [PATCH] Release v5.3.7: Implementato bypass cache per check aggiornamenti --- routes/api_routes.py | 7 ++++--- static/js/app.js | 13 +++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/routes/api_routes.py b/routes/api_routes.py index 8067544..2f55cb6 100644 --- a/routes/api_routes.py +++ b/routes/api_routes.py @@ -375,9 +375,10 @@ def get_server_update_status(): if not auth or auth['role'] != 'admin': return err("Non autorizzato", 403) - # Eseguiamo il controllo sincrono (ci mette max 1-2 secondi) ogni ora - # In questo modo il frontend riceve subito il risultato VERO, non quello della cache precedente - if time.time() - LAST_GITEA_CHECK_TIME > 3600: + force_check = request.args.get('force') == '1' + + # Eseguiamo il controllo sincrono se รจ passata 1 ora OPPURE se forzato dal client + if force_check or (time.time() - LAST_GITEA_CHECK_TIME > 3600): try: subprocess.run(['git', 'fetch'], timeout=10, cwd=BASE_DIR) local_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=BASE_DIR).decode('utf-8').strip() diff --git a/static/js/app.js b/static/js/app.js index ae3590b..9dcc6e3 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -1385,9 +1385,18 @@ async function checkPushStatus() { function urlB64ToUint8Array(base64String) { const padding = '='.repeat((4 - base64String.length % 4) % 4); const base64 = (base64String + padding).replace(/\-/g, '+').replace(/_/g, '/'); const rawData = window.atob(base64); const outputArray = new Uint8Array(rawData.length); for (let i = 0; i < rawData.length; ++i) outputArray[i] = rawData.charCodeAt(i); return outputArray; } -async function checkServerUpdate() { +async function checkServerUpdate(force = false) { if (!isAuthenticated || me.role !== 'admin') return; - try { const res = await fetch('/api/server_update/check'); if (!res.ok) return; const data = await res.json(); const btn = document.getElementById('server-update-btn'); if (btn) { btn.style.display = data.update_available ? 'inline-block' : 'none'; } } catch (e) { console.error(e); } + try { + const url = force ? '/api/server_update/check?force=1' : '/api/server_update/check'; + const res = await fetch(url); + if (!res.ok) return; + const data = await res.json(); + const btn = document.getElementById('server-update-btn'); + if (btn) { + btn.style.display = data.update_available ? 'inline-block' : 'none'; + } + } catch (e) { console.error(e); } } function confirmServerUpdate() {