Bug-fix: wireEncode "corrupts" implicit digest
* Removed wireEncde()
* Implemented finalize()
* Minor change to constructor to resolve code quality warnings (-Weffc++)
Refs: #3490
Change-Id: Ic943e12b0fd2d24dbfe46e7f5824051d308fb0ec
diff --git a/src/file-manifest.cpp b/src/file-manifest.cpp
index 7352699..fe4fec8 100644
--- a/src/file-manifest.cpp
+++ b/src/file-manifest.cpp
@@ -42,13 +42,6 @@
this->decodeContent();
}
-const Block&
-FileManifest::wireEncode()
-{
- encodeContent();
- return Data::wireEncode();
-}
-
template<ndn::encoding::Tag TAG>
size_t
FileManifest::encodeContent(ndn::EncodingImpl<TAG>& encoder) const {
@@ -126,6 +119,12 @@
return true;
}
+void
+FileManifest::finalize() {
+ m_catalog.shrink_to_fit();
+ encodeContent();
+}
+
void FileManifest::encodeContent() {
// Name
// <file_name>/ImplicitDigest
diff --git a/src/file-manifest.hpp b/src/file-manifest.hpp
index 0a46574..6ce957e 100644
--- a/src/file-manifest.hpp
+++ b/src/file-manifest.hpp
@@ -144,9 +144,15 @@
* @param wire the write to be decoded
* @throws Error if decoding fails
*/
- const Block&
- wireEncode();
- /// Encodes this FileManifest into the wire format and returns a Block with the contents
+
+ void
+ finalize();
+ /*
+ * \brief Performs all final processing on this manifest
+ *
+ * This method should be called once this manifest is populated and *must* be called before
+ * signing it or calling wireEncode().
+ */
private:
void
@@ -204,6 +210,11 @@
inline
FileManifest::FileManifest(const Block& block)
+: Data()
+, m_dataPacketSize(0)
+, m_catalogPrefix("")
+, m_catalog()
+, m_submanifestPtr(nullptr)
{
wireDecode(block);
}