Skip to content

Commit

Permalink
Merge pull request #311 from Bristol-Braille/310-sd-card-reset-loop
Browse files Browse the repository at this point in the history
Fix reset loop when unplugging sd card (while using usb too)
  • Loading branch information
woodcoder authored May 21, 2024
2 parents 0cffcb0 + 4cf98e0 commit 93a16d9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ui/initial_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,18 @@ 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]:
if current_book.startswith(path):
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):
Expand Down

0 comments on commit 93a16d9

Please sign in to comment.