From 432f9c30a39cafa92f56db87873cb573777e43be Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Thu, 7 Feb 2019 15:20:18 +0100 Subject: [PATCH 1/2] Remove unused variable url. --- src/reader.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index e7fc6a926..8390a2fe7 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -241,8 +241,6 @@ Entry Reader::getMainPage() const throw NoEntry(); } - string url = ""; - zim::Article article; if (this->zimFileHandler->getFileheader().hasMainPage()) { From 35d812a5f7c5792ce69e28ffe455c7cb0a59d6c7 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Thu, 7 Feb 2019 15:22:33 +0100 Subject: [PATCH 2/2] Ensure the book's `path` is absolute. We must use absolute path whenever possible. Relative path has sense only related to the "interaction" with the user (current directory, library location, ...). --- src/manager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/manager.cpp b/src/manager.cpp index c7c45b7e0..db926f49d 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -208,12 +208,16 @@ bool Manager::addBookFromPath(const std::string& pathToOpen, bool Manager::readBookFromPath(const std::string& path, kiwix::Book* book) { + std::string tmp_path = path; + if (isRelativePath(path)) { + tmp_path = computeAbsolutePath(getCurrentDirectory(), path); + } try { - kiwix::Reader reader(path); + kiwix::Reader reader(tmp_path); book->update(reader); book->setPathValid(true); } catch (const std::exception& e) { - std::cerr << "Invalid " << path << " : " << e.what() << std::endl; + std::cerr << "Invalid " << tmp_path << " : " << e.what() << std::endl; book->setPathValid(false); return false; }