diff --git a/src/contentmanager.cpp b/src/contentmanager.cpp index cbdda20..53510ca 100644 --- a/src/contentmanager.cpp +++ b/src/contentmanager.cpp @@ -878,6 +878,12 @@ void ContentManager::updateLibraryFromDir(QString monitorDir) const auto kiwixLib = mp_library->getKiwixLibrary(); kiwix::Manager manager(kiwixLib); bool needsRefresh = !removedZims.empty(); + for (auto bookPath : removedZims) { + try { + const auto book = kiwixLib->getBookByPath(bookPath.toStdString()); + mp_library->removeBookFromLibraryById(QString::fromStdString(book.getId())); + } catch (...) {} + } for (auto bookPath : addedZims) { if ( mp_library->isBeingDownloadedByUs(bookPath) ) { // qDebug() << "DBG: ContentManager::updateLibraryFromDir(): " @@ -887,12 +893,6 @@ void ContentManager::updateLibraryFromDir(QString monitorDir) needsRefresh |= manager.addBookFromPath(bookPath.toStdString()); } } - for (auto bookPath : removedZims) { - try { - const auto book = kiwixLib->getBookByPath(bookPath.toStdString()); - mp_library->removeBookFromLibraryById(QString::fromStdString(book.getId())); - } catch (...) {} - } if (needsRefresh) { emit(booksChanged()); setMonitorDirZims(monitorDir, newDirEntries);