From 97164c1f99992cabe2698a021545a8a17f946068 Mon Sep 17 00:00:00 2001 From: rreichenbach Date: Sat, 20 Jun 2026 20:45:01 -0700 Subject: [PATCH] fix the case where a pedalboard is specified in last.json but doesn't actually exist --- modalapistomp.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/modalapistomp.py b/modalapistomp.py index 4ae63852..84ffcc52 100755 --- a/modalapistomp.py +++ b/modalapistomp.py @@ -149,17 +149,27 @@ def main(): # Load the current pedalboard as "current" current_pedal_board_bundle = handler.get_current_pedalboard_bundle_path() - if not current_pedal_board_bundle: - # last.json missing or malformed — reset to first known pedalboard + if current_pedal_board_bundle and current_pedal_board_bundle in handler.pedalboards: + handler.set_current_pedalboard(handler.pedalboards[current_pedal_board_bundle]) + else: if not handler.pedalboard_list: - logging.error("No pedalboards found; cannot recover from missing/malformed last.json") + if current_pedal_board_bundle: + logging.error( + "last.json references %s but no pedalboards are available", + current_pedal_board_bundle, + ) + else: + logging.error("No pedalboards found; cannot recover from missing/malformed last.json") sys.exit(1) + if current_pedal_board_bundle: + logging.warning( + "last.json pedalboard %s not found; resetting to first available", + current_pedal_board_bundle, + ) pb = handler.pedalboard_list[0] write_last_json(handler.last_json_monitor.path, pb.bundle) handler.pedalboard_change(pb) handler.set_current_pedalboard(pb) - else: - handler.set_current_pedalboard(handler.pedalboards[current_pedal_board_bundle]) # Load system info. This can take a few seconds handler.system_info_load()