diff --git a/src/common/kiwix/library.cpp b/src/common/kiwix/library.cpp index 309bc72fa..5f2557ff7 100644 --- a/src/common/kiwix/library.cpp +++ b/src/common/kiwix/library.cpp @@ -91,35 +91,36 @@ namespace kiwix { /* Try to find it */ std::vector::iterator itr; for ( itr = this->books.begin(); itr != this->books.end(); ++itr ) { - if (itr->id == book.id && (itr->readOnly == book.readOnly || book.readOnly)) { + if (itr->id == book.id) { + if (itr->readOnly == book.readOnly || book.readOnly) { + itr->readOnly = book.readOnly; + + if (itr->path.empty()) + itr->path = book.path; + + if (itr->pathAbsolute.empty()) + itr->pathAbsolute = book.pathAbsolute; + + if (itr->url.empty()) + itr->url = book.url; + + if (itr->indexPath.empty()) { + itr->indexPath = book.indexPath; + itr->indexType = book.indexType; + } + + if (itr->indexPathAbsolute.empty()) { + itr->indexPathAbsolute = book.indexPathAbsolute; + itr->indexType = book.indexType; + } + + if (itr->faviconMimeType.empty()) { + itr->favicon = book.favicon; + itr->faviconMimeType = book.faviconMimeType; + } - itr->readOnly = book.readOnly; - - if (itr->path.empty()) - itr->path = book.path; - - if (itr->pathAbsolute.empty()) - itr->pathAbsolute = book.pathAbsolute; - - if (itr->url.empty()) - itr->url = book.url; - - if (itr->indexPath.empty()) { - itr->indexPath = book.indexPath; - itr->indexType = book.indexType; + return false; } - - if (itr->indexPathAbsolute.empty()) { - itr->indexPathAbsolute = book.indexPathAbsolute; - itr->indexType = book.indexType; - } - - if (itr->faviconMimeType.empty()) { - itr->favicon = book.favicon; - itr->faviconMimeType = book.faviconMimeType; - } - - return false; } }