fix(update): fast direct HTTP check & force cache bypass on check click (v1.3.7)

This commit is contained in:
sorcier committed 2026-11-04 03:42:14 +01:00
1 parent 7ccb2189e7
commit 54fe591355
5 files changed
+37 -8

No files matched your search

+24 -4
View File
@@ -2242,15 +2242,35 @@ try {
$remoteChangelog = [];
$remoteDate = '';
exec("git --git-dir={$appDir}/.git fetch origin main --quiet 2>/dev/null", $output, $code);
$remoteJsonRaw = shell_exec("git --git-dir={$appDir}/.git show origin/main:version.json 2>/dev/null");
if ($remoteJsonRaw) {
$remoteData = json_decode($remoteJsonRaw, true);
// 1. Interrogation directe via HTTP Raw (indépendant de .git et ultra-rapide)
$rawHttp = @shell_exec("curl -k -s --connect-timeout 4 \"https://git.sorcier-research.com/sorcier/NexusPBX/raw/branch/main/version.json\" 2>/dev/null");
if (empty($rawHttp)) {
$ctx = stream_context_create([
'http' => ['timeout' => 4],
'ssl' => ['verify_peer' => false, 'verify_peer_name' => false]
]);
$rawHttp = @file_get_contents("https://git.sorcier-research.com/sorcier/NexusPBX/raw/branch/main/version.json", false, $ctx);
}
if (!empty($rawHttp)) {
$remoteData = json_decode((string)$rawHttp, true);
if (is_array($remoteData) && !empty($remoteData['version'])) {
$remoteVer = (string)$remoteData['version'];
$remoteChangelog = $remoteData['changelog'] ?? [];
$remoteDate = $remoteData['release_date'] ?? '';
}
} else {
// 2. Fallback local Git si indisponibilité du serveur HTTP
exec("git --git-dir={$appDir}/.git fetch origin main --quiet 2>/dev/null", $output, $code);
$remoteJsonRaw = shell_exec("git --git-dir={$appDir}/.git show origin/main:version.json 2>/dev/null");
if ($remoteJsonRaw) {
$remoteData = json_decode($remoteJsonRaw, true);
if (is_array($remoteData) && !empty($remoteData['version'])) {
$remoteVer = (string)$remoteData['version'];
$remoteChangelog = $remoteData['changelog'] ?? [];
$remoteDate = $remoteData['release_date'] ?? '';
}
}
}
$hasUpdate = version_compare($remoteVer, $currentVer, '>');
+7
View File
@@ -5745,11 +5745,17 @@ async function checkSystemUpdate(notify = false) {
return;
} catch (_) {}
}
} else {
localStorage.removeItem(STORAGE_KEY_TIME);
localStorage.removeItem(STORAGE_KEY_DATA);
}
let origBtnHtml = null;
if (btnCheck) {
btnCheck.disabled = true;
btnCheck.classList.add('opacity-50');
origBtnHtml = btnCheck.innerHTML;
btnCheck.innerHTML = `<svg class="animate-spin w-4 h-4 text-cyan-400" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8H4z"></path></svg><span>Vérification en cours...</span>`;
}
try {
@@ -5777,6 +5783,7 @@ async function checkSystemUpdate(notify = false) {
if (btnCheck) {
btnCheck.disabled = false;
btnCheck.classList.remove('opacity-50');
if (origBtnHtml) btnCheck.innerHTML = origBtnHtml;
}
}