From f6f4d8426af5befabbb7a3f2ad5fbdae0e5bef5f Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Fri, 28 Dec 2018 10:32:01 +0100 Subject: [PATCH] comments + really compute md5 on uncompressed data --- src/internfile/mh_xslt.cpp | 6 ++++++ src/utils/readfile.cpp | 19 +++++++++---------- src/utils/readfile.h | 7 +++---- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/internfile/mh_xslt.cpp b/src/internfile/mh_xslt.cpp index 8afbc83a..56d6429a 100644 --- a/src/internfile/mh_xslt.cpp +++ b/src/internfile/mh_xslt.cpp @@ -32,6 +32,12 @@ using namespace std; +// Do we need this? It would need to be called from recollinit +// Call once, not reentrant +// xmlInitParser(); +// LIBXML_TEST_VERSION; +// Probably not: xmlCleanupParser(); + class FileScanXML : public FileScanDo { public: diff --git a/src/utils/readfile.cpp b/src/utils/readfile.cpp index ae2edf16..d51da8b2 100644 --- a/src/utils/readfile.cpp +++ b/src/utils/readfile.cpp @@ -511,14 +511,6 @@ bool file_scan(const string& fn, FileScanDo* doer, int64_t startoffs, FileScanSourceFile source(doer, fn, startoffs, cnttoread, reason); FileScanUpstream *up = &source; - // We compute the MD5 on the uncompressed data, so insert this - // right at the source. - string digest; - FileScanMd5 md5filter(digest); - if (md5p) { - md5filter.insertAtSink(doer, up); - up = &md5filter; - } #if defined(READFILE_ENABLE_ZLIB) GzFilter gzfilter; @@ -528,6 +520,15 @@ bool file_scan(const string& fn, FileScanDo* doer, int64_t startoffs, } #endif + // We compute the MD5 on the uncompressed data, so insert this + // right at the source (after the decompressor). + string digest; + FileScanMd5 md5filter(digest); + if (md5p) { + md5filter.insertAtSink(doer, up); + up = &md5filter; + } + bool ret = source.scan(); if (md5p) { @@ -572,8 +573,6 @@ bool string_scan(const char *data, size_t cnt, FileScanDo* doer, FileScanSourceBuffer source(doer, data, cnt, reason); FileScanUpstream *up = &source; - // We compute the MD5 on the uncompressed data, so insert this - // right at the source. string digest; FileScanMd5 md5filter(digest); if (md5p) { diff --git a/src/utils/readfile.h b/src/utils/readfile.h index 64323965..854fcec1 100644 --- a/src/utils/readfile.h +++ b/src/utils/readfile.h @@ -65,14 +65,13 @@ public: bool file_scan(const std::string& fn, FileScanDo* doer, int64_t startoffs, int64_t cnttoread, std::string *reason, std::string *md5p); -/** Same as file_scan, from a memory buffer */ -bool string_scan(const char *data, size_t cnt, FileScanDo* doer, - std::string *reason, std::string *md5p); - /** Same as above, not offset/cnt/md5 */ bool file_scan(const std::string& filename, FileScanDo* doer, std::string *reason); +/** Same as file_scan, from a memory buffer. No libz processing */ +bool string_scan(const char *data, size_t cnt, FileScanDo* doer, + std::string *reason, std::string *md5p); #if defined(READFILE_ENABLE_MINIZ) /* Process a zip archive member */