From 38049d92a819f59fa2bd875d140751c52be7cde9 Mon Sep 17 00:00:00 2001 From: refracta <58779799+refracta@users.noreply.github.com> Date: Sun, 1 Jun 2025 16:09:40 +0900 Subject: [PATCH] Filter out missing game directories --- config.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/config.py b/config.py index cf04d772..7f548d07 100755 --- a/config.py +++ b/config.py @@ -1,4 +1,5 @@ import logging +import os try: from collections import OrderedDict @@ -169,6 +170,23 @@ def create_game(game_key, overrides=None): # Combine all game lists into one games = OrderedDict(trunk + stable_versions + forks) +# Filter out games whose installation directories are missing. Without this +# check the webserver can hang while loading games when a version was not +# installed correctly. +def _filter_installed(game_dict): + base_dir = os.environ.get('CHROOT_CRAWL_BASEDIR', '%%CHROOT_CRAWL_BASEDIR%%') + root = os.environ.get('DGL_CHROOT', '%%DGL_CHROOT%%') + filtered = OrderedDict() + for key, cfg in game_dict.items(): + game_dir = os.path.join(root, base_dir, f"crawl-{cfg['version']}") + if os.path.isdir(game_dir): + filtered[key] = cfg + else: + logging.warning("Skipping game %s: missing directory %s", key, game_dir) + return filtered + +games = _filter_installed(games) + dgl_status_file = "%%CHROOT_WEBDIR%%/run/status" forks_milestones = [ "%%CHROOT_CRAWL_BASEDIR%%/crawl-dcssca/saves/milestones",