From bf16706d50b3d54c090ba198601fbbf079eeb81c Mon Sep 17 00:00:00 2001 From: dockes Date: Sat, 17 Jan 2009 14:56:52 +0000 Subject: [PATCH] added compressedfilemaxkbs --- src/internfile/internfile.cpp | 26 +++++++++++++++++--------- src/qtgui/confgui/confguiindex.cpp | 12 ++++++++++++ src/sampleconf/recoll.conf.in | 6 ++++++ 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/internfile/internfile.cpp b/src/internfile/internfile.cpp index 1060aa26..da662584 100644 --- a/src/internfile/internfile.cpp +++ b/src/internfile/internfile.cpp @@ -158,16 +158,24 @@ FileInterner::FileInterner(const std::string &f, const struct stat *stp, // identification, then do the rest with the temp file. listucmd; if (m_cfg->getUncompressor(l_mime, ucmd)) { - if (!uncompressfile(m_cfg, m_fn, ucmd, m_tdir, m_tfile)) { - return; + // Check for compressed size limit + int maxkbs = -1; + if (!m_cfg->getConfParam("compressedfilemaxkbs", &maxkbs) || + maxkbs < 0 || !stp || int(stp->st_size / 1024) < maxkbs) { + if (!uncompressfile(m_cfg, m_fn, ucmd, m_tdir, m_tfile)) { + return; + } + LOGDEB1(("internfile: after ucomp: m_tdir %s, tfile %s\n", + m_tdir.c_str(), m_tfile.c_str())); + m_fn = m_tfile; + // Note: still using the original file's stat. right ? + l_mime = mimetype(m_fn, stp, m_cfg, usfci); + if (l_mime.empty() && imime) + l_mime = *imime; + } else { + LOGINFO(("internfile: %s over size limit %d kbs\n", + m_fn.c_str(), maxkbs)); } - LOGDEB1(("internfile: after ucomp: m_tdir %s, tfile %s\n", - m_tdir.c_str(), m_tfile.c_str())); - m_fn = m_tfile; - // Note: still using the original file's stat. right ? - l_mime = mimetype(m_fn, stp, m_cfg, usfci); - if (l_mime.empty() && imime) - l_mime = *imime; } } diff --git a/src/qtgui/confgui/confguiindex.cpp b/src/qtgui/confgui/confguiindex.cpp index 3e5f73f5..853816d4 100644 --- a/src/qtgui/confgui/confguiindex.cpp +++ b/src/qtgui/confgui/confguiindex.cpp @@ -353,6 +353,18 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config) "cannot be identified or processed (no or " "unsupported mime type). Default true")); m_widgets.push_back(eafln); + + ConfLink lnkzfmaxkbs(new ConfLinkRclRep(config, + "compressedfilemaxkbs")); + ConfParamIntW *ezfmaxkbs = new + ConfParamIntW(m_groupbox, lnkzfmaxkbs, + tr("Max. compressed file size (KB)"), + tr("This value sets a threshold beyond which compressed" + "files will not be processed. Set to -1 for no " + "limit, to 0 for no decompression ever."), + -1, 1000000); + m_widgets.push_back(ezfmaxkbs); + vboxLayout->addWidget(m_groupbox); subDirChanged(); } diff --git a/src/sampleconf/recoll.conf.in b/src/sampleconf/recoll.conf.in index 2be91535..c0a6293c 100644 --- a/src/sampleconf/recoll.conf.in +++ b/src/sampleconf/recoll.conf.in @@ -91,6 +91,12 @@ usesystemfilecommand = 1 # know? (we can otherwise just ignore them) indexallfilenames = 1 +# Size limit for compressed files. We need to decompress these in a +# temporary directory for identification, which can be wasteful in some +# cases. Limit the waste. Negative means no limit. 0 results in no +# processing of any compressed file +# compressedfilemaxkbs = -1 + # Length of abstracts we store while indexing. Longer will make for a # bigger db # idxabsmlen = 250