From 8973e5f8cc2909c1459df6f269db0a738e86bca5 Mon Sep 17 00:00:00 2001 From: rdbende Date: Sat, 15 Jun 2024 18:28:20 +0200 Subject: [PATCH] Not all books from a storage location were removed --- cozy/view_model/storages_view_model.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cozy/view_model/storages_view_model.py b/cozy/view_model/storages_view_model.py index c238e40b..ac735bbb 100644 --- a/cozy/view_model/storages_view_model.py +++ b/cozy/view_model/storages_view_model.py @@ -95,17 +95,17 @@ def remove(self, model: Storage) -> None: if model.default: return - model.delete() - self._model.invalidate() + storage_path = model.path + chapters_to_remove = [] - storage_path = str(model.path) for book in self._library.books: - chapters_to_remove = [ - c for c in book.chapters if c.file.startswith(storage_path) - ] + chapters_to_remove.extend([c for c in book.chapters if c.file.startswith(storage_path)]) + + for chapter in set(chapters_to_remove): + chapter.delete() - for chapter in chapters_to_remove: - chapter.delete() + model.delete() + self._model.invalidate() self.emit_event("storage-removed", model) self._notify("storage_locations")