From 4cf98e027282e4ae9c918bcb1b4e02b528384c57 Mon Sep 17 00:00:00 2001 From: Andy Wood Date: Tue, 21 May 2024 11:25:58 +0100 Subject: [PATCH] Ignore paths beginning with sd-card (rather than failing with variable used before initialisation error) --- ui/initial_state.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/initial_state.py b/ui/initial_state.py index 18e8550..5c16aa9 100644 --- a/ui/initial_state.py +++ b/ui/initial_state.py @@ -71,6 +71,7 @@ def swap_library(current_book, books): """ config = config_loader.load() library = config.get('files', {}).get('library', []) + rel_book = None # check for expected path, for backward compatibility with standalone unit for path in ['front-usb' + os.path.sep, 'back-usb' + os.path.sep]: @@ -78,6 +79,10 @@ def swap_library(current_book, books): rel_book = current_book[len(path):] break + if rel_book is None: + log.info(f'current book not on swappable device ({current_book})') + return + # see if we can find it on a different swappable device path for lib in library: if lib.get('swappable', False):