diff --git a/cozy/model/library.py b/cozy/model/library.py index e25dcb8c..d377dece 100644 --- a/cozy/model/library.py +++ b/cozy/model/library.py @@ -93,10 +93,8 @@ def rebase_path(self, old_path: str, new_path: str): self.emit_event_main_thread("rebase-started") chapter_count = len(self.chapters) - progress = 0 - for chapter in self.chapters: + for progress, chapter in enumerate(self.chapters, 1): if chapter.file.startswith(old_path): - progress += 1 chapter.file = chapter.file.replace(old_path, new_path) self.emit_event_main_thread("rebase-progress", progress / chapter_count) diff --git a/cozy/view_model/book_detail_view_model.py b/cozy/view_model/book_detail_view_model.py index e3d2973a..4eb7e9c9 100644 --- a/cozy/view_model/book_detail_view_model.py +++ b/cozy/view_model/book_detail_view_model.py @@ -196,7 +196,7 @@ def _on_playback_speed_changed(self): self._notify("total_text") def _on_offline_cache_event(self, event, message): - if not self._book or self._book.id != message.id: + if not (message and self._book) or self._book.id != message.id: return if event in {"book-offline-removed", "book-offline"}: