Merge pull request #193 from naturallaw777/copilot/fix-update-system-flow
fix: skip update flow when no updates are available
This commit is contained in:
@@ -2375,6 +2375,10 @@ async def api_updates_run():
|
|||||||
if status == "RUNNING":
|
if status == "RUNNING":
|
||||||
return {"ok": True, "status": "already_running"}
|
return {"ok": True, "status": "already_running"}
|
||||||
|
|
||||||
|
available = await loop.run_in_executor(None, check_for_updates)
|
||||||
|
if not available:
|
||||||
|
return {"ok": True, "status": "no_updates"}
|
||||||
|
|
||||||
# Clear stale status and log BEFORE starting the unit
|
# Clear stale status and log BEFORE starting the unit
|
||||||
_write_update_status("RUNNING")
|
_write_update_status("RUNNING")
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -3,6 +3,30 @@
|
|||||||
// ── Update modal ──────────────────────────────────────────────────
|
// ── Update modal ──────────────────────────────────────────────────
|
||||||
|
|
||||||
function openUpdateModal() {
|
function openUpdateModal() {
|
||||||
|
if (!$modal) return;
|
||||||
|
apiFetch("/api/updates/check")
|
||||||
|
.then(function(data) {
|
||||||
|
if (!data.available) {
|
||||||
|
_updateLog = "";
|
||||||
|
_updateLogOffset = 0;
|
||||||
|
_updateFinished = true;
|
||||||
|
if ($modalLog) $modalLog.textContent = "";
|
||||||
|
if ($modalStatus) $modalStatus.textContent = "✓ System is already up to date";
|
||||||
|
if ($modalSpinner) $modalSpinner.classList.remove("spinning");
|
||||||
|
if ($btnReboot) $btnReboot.style.display = "none";
|
||||||
|
if ($btnSave) $btnSave.style.display = "none";
|
||||||
|
if ($btnCloseModal) $btnCloseModal.disabled = false;
|
||||||
|
$modal.classList.add("open");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_doOpenUpdateModal();
|
||||||
|
})
|
||||||
|
.catch(function() {
|
||||||
|
_doOpenUpdateModal();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function _doOpenUpdateModal() {
|
||||||
if (!$modal) return;
|
if (!$modal) return;
|
||||||
_updateLog = "";
|
_updateLog = "";
|
||||||
_updateLogOffset = 0;
|
_updateLogOffset = 0;
|
||||||
@@ -37,6 +61,15 @@ function startUpdate() {
|
|||||||
return response.json();
|
return response.json();
|
||||||
})
|
})
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
|
if (data.status === "no_updates") {
|
||||||
|
if ($modalStatus) $modalStatus.textContent = "✓ System is already up to date";
|
||||||
|
if ($modalSpinner) $modalSpinner.classList.remove("spinning");
|
||||||
|
if ($btnReboot) $btnReboot.style.display = "none";
|
||||||
|
if ($btnSave) $btnSave.style.display = "none";
|
||||||
|
if ($btnCloseModal) $btnCloseModal.disabled = false;
|
||||||
|
_updateFinished = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (data.status === "already_running") appendLog("[Update already in progress, attaching…]\n\n");
|
if (data.status === "already_running") appendLog("[Update already in progress, attaching…]\n\n");
|
||||||
if ($modalStatus) $modalStatus.textContent = "Updating…";
|
if ($modalStatus) $modalStatus.textContent = "Updating…";
|
||||||
startUpdatePoll();
|
startUpdatePoll();
|
||||||
|
|||||||
Reference in New Issue
Block a user