diff --git a/src/common/kiwix/library.cpp b/src/common/kiwix/library.cpp index 0b4baa1a2..a99a587ae 100644 --- a/src/common/kiwix/library.cpp +++ b/src/common/kiwix/library.cpp @@ -59,6 +59,28 @@ namespace kiwix { } bool Library::addBook(const Book &book) { + + /* Try to find it */ + std::vector::iterator itr; + for ( itr = this->books.begin(); itr != this->books.end(); ++itr ) { + if (itr->id == book.id) { + + if (itr->path.empty()) + itr->path = book.path; + + if (itr->url.empty()) + itr->url = book.url; + + if (itr->indexPath.empty()) { + itr->indexPath = book.indexPath; + itr->indexType = book.indexType; + } + + return false; + } + } + + /* otherwise */ this->books.push_back(book); return true; } diff --git a/src/common/kiwix/manager.cpp b/src/common/kiwix/manager.cpp index fba5f2a62..5589e3d69 100644 --- a/src/common/kiwix/manager.cpp +++ b/src/common/kiwix/manager.cpp @@ -32,7 +32,10 @@ namespace kiwix { bool Manager::parseXmlDom(const pugi::xml_document &doc, const bool readOnly) { pugi::xml_node libraryNode = doc.child("library"); - library.current = libraryNode.attribute("current").value(); + + if (strlen(libraryNode.attribute("current").value())) + library.current = libraryNode.attribute("current").value(); + string libraryVersion = libraryNode.attribute("version").value(); for (pugi::xml_node bookNode = libraryNode.child("book"); bookNode; bookNode = bookNode.next_sibling("book")) { @@ -294,6 +297,7 @@ namespace kiwix { if (mode == LASTOPEN) { std::sort(library.books.begin(), library.books.end(), kiwix::Book::sortByLastOpen); for ( itr = library.books.begin(); itr != library.books.end(); ++itr ) { + if (!itr->last.empty()) this->bookIdList.push_back(itr->id); } } else if (mode == REMOTE) {