From b293dc8033e92fb6b27d9dc9911a5e8e8b8985da Mon Sep 17 00:00:00 2001 From: Steven Engelbert Date: Mon, 2 Dec 2024 15:23:39 -0500 Subject: [PATCH] Create function to validate current persist_logs state prior to updates, then set to true if it is false with sane minimum auto-off delay --- CHANGELOG.md | 4 ++++ amplipi/updater/asgi.py | 16 ++++++++++++++++ amplipi/updater/static/index.html | 5 +++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ce9c03ae..25defefbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # AmpliPi Software Releases +## 0.4.6 +* System + * Automatically persist logs during (and for a short time after) updates + ## 0.4.5 * Web App * Ensure that abnormally-shaped album art is still horizontally centered diff --git a/amplipi/updater/asgi.py b/amplipi/updater/asgi.py index b96b7b5e2..9265ca8aa 100644 --- a/amplipi/updater/asgi.py +++ b/amplipi/updater/asgi.py @@ -280,11 +280,27 @@ def download(url, file_name): # TODO: verify file has amplipi version +def persist_logs_during_update(): + """Used during system updates to ensure persist logs is activated and has a minimum delay""" + persist_data = get_log_persist_state() + existing_persist = persist_data.persist_logs + existing_delay = persist_data.auto_off_delay + # If persist logs is already on and has a larger delay, keep that delay; otherwise ensure it has our sane minimum for support + if existing_persist and (existing_delay > 3 or existing_delay == 0): + data = Persist_Logs(persist_logs=True, auto_off_delay=existing_delay) + toggle_persist_logs(data=data) + else: + # Three days is an arbitrary number, picked to ensure the next few days of usage post-update are captured for support cases + data = Persist_Logs(persist_logs=True, auto_off_delay=3) + toggle_persist_logs(data=data) + + @router.post("/update/download") async def download_update(info: ReleaseInfo): """ Download the update """ logger.info(f'downloading update from: {info.url}') try: + persist_logs_during_update() os.makedirs('web/uploads', exist_ok=True) download(info.url, 'web/uploads/update.tar.gz') return 200 diff --git a/amplipi/updater/static/index.html b/amplipi/updater/static/index.html index 3412bd7f6..7dfbefef3 100644 --- a/amplipi/updater/static/index.html +++ b/amplipi/updater/static/index.html @@ -44,7 +44,7 @@

AmpliPi

Custom Update