fixed stale info
This commit is contained in:
@@ -167,6 +167,15 @@ def _read_update_status() -> str:
|
|||||||
return "IDLE"
|
return "IDLE"
|
||||||
|
|
||||||
|
|
||||||
|
def _write_update_status(status: str):
|
||||||
|
"""Write to the status file."""
|
||||||
|
try:
|
||||||
|
with open(UPDATE_STATUS, "w") as f:
|
||||||
|
f.write(status)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _read_log(offset: int = 0) -> tuple[str, int]:
|
def _read_log(offset: int = 0) -> tuple[str, int]:
|
||||||
"""Read the update log file from the given byte offset.
|
"""Read the update log file from the given byte offset.
|
||||||
Returns (new_text, new_offset)."""
|
Returns (new_text, new_offset)."""
|
||||||
@@ -318,6 +327,14 @@ async def api_updates_run():
|
|||||||
if status == "RUNNING":
|
if status == "RUNNING":
|
||||||
return {"ok": True, "status": "already_running"}
|
return {"ok": True, "status": "already_running"}
|
||||||
|
|
||||||
|
# Clear stale status and log BEFORE starting the unit
|
||||||
|
_write_update_status("RUNNING")
|
||||||
|
try:
|
||||||
|
with open(UPDATE_LOG, "w") as f:
|
||||||
|
f.write("")
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
# Reset failed state if any
|
# Reset failed state if any
|
||||||
await asyncio.create_subprocess_exec(
|
await asyncio.create_subprocess_exec(
|
||||||
"systemctl", "reset-failed", UPDATE_UNIT,
|
"systemctl", "reset-failed", UPDATE_UNIT,
|
||||||
|
|||||||
Reference in New Issue
Block a user