From 435e7ac76fb084f0602820df6ab8c4036ca9d8fb Mon Sep 17 00:00:00 2001 From: kelson42 Date: Tue, 6 Aug 2013 13:09:34 +0800 Subject: [PATCH 1/2] + fix in ro library mgmt --- src/common/kiwix/library.cpp | 55 ++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 27 deletions(-) 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; } } From bd81a2c6624b96bf26ff730de449b2db1c9a1493 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Tue, 6 Aug 2013 13:43:26 +0800 Subject: [PATCH 2/2] + fix mgmt of custom libraries with relative paths --- src/common/kiwix/library.cpp | 8 ++++---- src/common/kiwix/manager.cpp | 8 +------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/common/kiwix/library.cpp b/src/common/kiwix/library.cpp index 5f2557ff7..4ee7a45f9 100644 --- a/src/common/kiwix/library.cpp +++ b/src/common/kiwix/library.cpp @@ -92,10 +92,10 @@ namespace kiwix { std::vector::iterator itr; for ( itr = this->books.begin(); itr != this->books.end(); ++itr ) { if (itr->id == book.id) { - if (itr->readOnly == book.readOnly || book.readOnly) { + if (!itr->readOnly) { itr->readOnly = book.readOnly; - if (itr->path.empty()) + if (itr->path.empty()) itr->path = book.path; if (itr->pathAbsolute.empty()) @@ -118,9 +118,9 @@ namespace kiwix { itr->favicon = book.favicon; itr->faviconMimeType = book.faviconMimeType; } - - return false; } + + return false; } } diff --git a/src/common/kiwix/manager.cpp b/src/common/kiwix/manager.cpp index efb18c71b..abf2d2868 100644 --- a/src/common/kiwix/manager.cpp +++ b/src/common/kiwix/manager.cpp @@ -142,9 +142,6 @@ namespace kiwix { if (!itr->path.empty()) bookNode.append_attribute("path") = itr->path.c_str(); - if (!itr->pathAbsolute.empty()) - bookNode.append_attribute("pathAbsolute") = itr->pathAbsolute.c_str(); - if (!itr->last.empty() && itr->last != "undefined") { bookNode.append_attribute("last") = itr->last.c_str(); } @@ -152,9 +149,6 @@ namespace kiwix { if (!itr->indexPath.empty()) bookNode.append_attribute("indexPath") = itr->indexPath.c_str(); - if (!itr->indexPathAbsolute.empty()) - bookNode.append_attribute("indexPathAbsolute") = itr->indexPathAbsolute.c_str(); - if (!itr->indexPath.empty() || !itr->indexPathAbsolute.empty()) { if (itr->indexType == XAPIAN) bookNode.append_attribute("indexType") = "xapian"; @@ -490,7 +484,7 @@ namespace kiwix { ok = false; if (ok == true && mode == REMOTE && (!itr->path.empty() || itr->url.empty())) - ok = false; + ok = false; if (ok == true && maxSize != 0 && (unsigned int)atoi(itr->size.c_str()) > maxSize * 1024 * 1024) ok = false;