Skip to content

Commit

Permalink
Not all books from a storage location were removed
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Jun 15, 2024
1 parent 5e262b8 commit 8973e5f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cozy/view_model/storages_view_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 8973e5f

Please sign in to comment.