From 8df7a776de36aa59e3b7d2e05790ef020a3cd371 Mon Sep 17 00:00:00 2001 From: Lenoch <81lennoch@gmail.com> Date: Fri, 8 Nov 2024 15:01:41 +0100 Subject: [PATCH] Fix auto-update to restart immediately on startup When `startup=True`, the script will not wait for 5 AM to restart after an update. --- main.py | 2 +- updater.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 2eaeef6..9442fb4 100644 --- a/main.py +++ b/main.py @@ -13,7 +13,7 @@ # Change directory to the main.py dir os.chdir(os.path.dirname(os.path.abspath(__file__))) -updater.auto_update() +updater.auto_update(startup=True) def load_config(): with open('config.yml', 'r') as config_file: diff --git a/updater.py b/updater.py index 726f1b4..c7361c8 100644 --- a/updater.py +++ b/updater.py @@ -131,7 +131,7 @@ def update_to_latest_release(tag_name): set_installed_version(tag_name) # Main updater logic -def auto_update(): +def auto_update(startup=False): repo = config.get('update-source') # Get the latest release @@ -153,7 +153,7 @@ def auto_update(): if check_build_status(repo, last_commit_sha): print(f"Build successful. Updating to {release_tag}.") update_to_latest_release(release_tag) - if __name__ != "__main__": + if __name__ != "__main__" and not startup: restart_script() else: print("Build failed or not successful. Update aborted.")