From 3f34e0e295c9cc50ea3ef167aa774ebecaef49e5 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 12 Apr 2026 18:48:31 +0200 Subject: [PATCH] fixed #14665 - donate-cpu-server.py: improved handling of corrupt `package-index.txt` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Marjamäki --- tools/donate-cpu-server.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/donate-cpu-server.py b/tools/donate-cpu-server.py index 6f44ea679a7..898f2f1c1ae 100755 --- a/tools/donate-cpu-server.py +++ b/tools/donate-cpu-server.py @@ -26,7 +26,7 @@ # Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/ # Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic # changes) -SERVER_VERSION = "1.3.68" +SERVER_VERSION = "1.3.69" # TODO: fetch from GitHub tags OLD_VERSION = '2.20.0' @@ -1612,9 +1612,13 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa packageIndex = 0 if os.path.isfile('package-index.txt'): with open('package-index.txt', 'rt') as f: - packageIndex = int(f.read()) - if packageIndex < 0 or packageIndex >= len(packages): - packageIndex = 0 + # TODO: the file might be empty - fixture out how this might happen + try: + packageIndex = int(f.read()) + except ValueError as e: + logging.error("failed to convert package index to int", exc_info=sys.exc_info()) + if packageIndex <= 0 or packageIndex >= len(packages): + packageIndex = int(time.time()) % len(packages) server_address_port = 8000 if '--test' in sys.argv[1:]: