From fe6d5fa93e114d495e419546520632d3bc78edeb Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 16 Oct 2018 17:53:18 +0200 Subject: [PATCH] Store the downloadId in the book (and in the library). --- include/book.h | 3 +++ src/book.cpp | 3 +++ src/library.cpp | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/include/book.h b/include/book.h index b79358349..434ba745e 100644 --- a/include/book.h +++ b/include/book.h @@ -69,6 +69,7 @@ class Book const uint64_t& getSize() const { return m_size; } const std::string& getFavicon() const { return m_favicon; } const std::string& getFaviconMimeType() const { return m_faviconMimeType; } + const std::string& getDownloadId() const { return m_downloadId; } void setReadOnly(bool readOnly) { m_readOnly = readOnly; } void setId(const std::string& id) { m_id = id; } @@ -91,9 +92,11 @@ class Book void setSize(uint64_t size) { m_size = size; } void setFavicon(const std::string& favicon) { m_favicon = favicon; } void setFaviconMimeType(const std::string& faviconMimeType) { m_faviconMimeType = faviconMimeType; } + void setDownloadId(const std::string& downloadId) { m_downloadId = downloadId; } protected: std::string m_id; + std::string m_downloadId; std::string m_path; bool m_pathValid; std::string m_indexPath; diff --git a/src/book.cpp b/src/book.cpp index eb0798b81..52e2d50cc 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -123,6 +123,9 @@ void Book::updateFromXml(const pugi::xml_node& node, const std::string& baseDir) m_size = strtoull(ATTR("size"), 0, 0); m_favicon = base64_decode(ATTR("favicon")); m_faviconMimeType = ATTR("faviconMimeType"); + try { + m_downloadId = ATTR("downloadId"); + } catch(...) {} } #undef ATTR diff --git a/src/library.cpp b/src/library.cpp index fea5d83b2..28abb90bf 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -155,6 +155,10 @@ bool Library::writeToFile(const std::string& path) { if (!book.getSize()) { bookNode.append_attribute("size") = to_string(book.getSize()).c_str(); } + + if (!book.getDownloadId().empty()) { + bookNode.append_attribute("downloadId") = book.getDownloadId().c_str(); + } } }