diff --git a/frappyman.py b/frappyman.py index a580159..97c5abb 100644 --- a/frappyman.py +++ b/frappyman.py @@ -100,10 +100,15 @@ def summarize_server_state(givencfgs, ourcfgs, sealist, sea_info, strict=False): addons = set() seacfgs = {} remarks = {} + inverted = defaultdict(set) + all_of = defaultdict(set) + for cfg, seacfg in sea_info.items(): + inverted[seacfg].add(cfg) + all_of[seacfg.rsplit('.', 1)[-1]].add(cfg) for seacfg, seacfgfile, key in zip_longest(sealist, seacfgfiles, ('main', 'stick')): if not seacfg: continue - available = sea_info.get(seacfg + SEAEXT.get(key, '.addon')) + available = inverted[seacfg + SEAEXT.get(key, '.addon')] if available: proposed = list(available)[0] if len(available) == 1 else None if not proposed: @@ -142,10 +147,6 @@ def summarize_server_state(givencfgs, ourcfgs, sealist, sea_info, strict=False): remarks[pkey] = 'missing frappy config' error = True restart = set() - available = {s: set() for s in ('.config', '.stick', '.addon')} - for seacfg, cfg in sea_info.items(): - ext = seacfg.rsplit('.', 1)[-1] - available[ext].add(cfg) for key, running in frappycfgs.items(): if running: if key in ('main', 'stick'): @@ -154,7 +155,7 @@ def summarize_server_state(givencfgs, ourcfgs, sealist, sea_info, strict=False): service = 'addons' addons.add(running) if not seacfgs.get(key): - if running in available[SEAEXT.get(key, '.addon')]: + if running in all_of[SEAEXT.get(key, '.addon')]: restart.add(service) remarks[key] = 'restart to start sea' elif givencfgs.get(key) != running: