simplified temp file handling for compressed documents and, for querying, implemented caching for last file uncompressed
This commit is contained in:
parent
042a54ef27
commit
41ada1e2ca
14 changed files with 221 additions and 138 deletions
|
@ -225,8 +225,8 @@ bool BeagleQueueIndexer::indexFromCache(const string& udi)
|
|||
return true;
|
||||
} else {
|
||||
Rcl::Doc doc;
|
||||
FileInterner interner(data, m_config, m_tmpdir,
|
||||
FileInterner::FIF_doUseInputMimetype,
|
||||
FileInterner interner(data, m_config,
|
||||
FileInterner::FIF_doUseInputMimetype,
|
||||
dotdoc.mimetype);
|
||||
FileInterner::Status fis;
|
||||
try {
|
||||
|
@ -434,7 +434,7 @@ BeagleQueueIndexer::processone(const string &path,
|
|||
// to use beagle-generated fields like beagle:inurl
|
||||
doc.meta = dotdoc.meta;
|
||||
|
||||
FileInterner interner(path, stp, m_config, m_tmpdir,
|
||||
FileInterner interner(path, stp, m_config,
|
||||
FileInterner::FIF_doUseInputMimetype,
|
||||
&dotdoc.mimetype);
|
||||
FileInterner::Status fis;
|
||||
|
|
|
@ -71,7 +71,6 @@ private:
|
|||
Rcl::Db *m_db;
|
||||
BeagleQueueCache *m_cache;
|
||||
string m_queuedir;
|
||||
TempDir m_tmpdir;
|
||||
DbIxStatusUpdater *m_updater;
|
||||
bool m_nocacheindex;
|
||||
|
||||
|
|
|
@ -534,7 +534,6 @@ void *FsIndexerInternfileWorker(void * fsp)
|
|||
FsIndexer *fip = (FsIndexer*)fsp;
|
||||
WorkQueue<InternfileTask*> *tqp = &fip->m_iwqueue;
|
||||
DebugLog::getdbl()->setloglevel(fip->m_loglevel);
|
||||
TempDir tmpdir;
|
||||
RclConfig myconf(*(fip->m_stableconfig));
|
||||
|
||||
InternfileTask *tsk = 0;
|
||||
|
@ -544,7 +543,7 @@ void *FsIndexerInternfileWorker(void * fsp)
|
|||
return (void*)1;
|
||||
}
|
||||
LOGDEB0(("FsIndexerInternfileWorker: task fn %s\n", tsk->fn.c_str()));
|
||||
if (fip->processonefile(&myconf, tmpdir, tsk->fn, &tsk->statbuf,
|
||||
if (fip->processonefile(&myconf, tsk->fn, &tsk->statbuf,
|
||||
tsk->localfields, tsk->mdreapers) !=
|
||||
FsTreeWalker::FtwOk) {
|
||||
LOGERR(("FsIndexerInternfileWorker: processone failed\n"));
|
||||
|
@ -612,13 +611,12 @@ FsIndexer::processone(const std::string &fn, const struct stat *stp,
|
|||
}
|
||||
#endif
|
||||
|
||||
return processonefile(m_config, m_tmpdir, fn, stp, m_localfields,
|
||||
m_mdreapers);
|
||||
return processonefile(m_config, fn, stp, m_localfields, m_mdreapers);
|
||||
}
|
||||
|
||||
|
||||
FsTreeWalker::Status
|
||||
FsIndexer::processonefile(RclConfig *config, TempDir& tmpdir,
|
||||
FsIndexer::processonefile(RclConfig *config,
|
||||
const std::string &fn, const struct stat *stp,
|
||||
const map<string, string>& localfields,
|
||||
const vector<MDReaper>& mdreapers)
|
||||
|
@ -659,7 +657,7 @@ FsIndexer::processonefile(RclConfig *config, TempDir& tmpdir,
|
|||
LOGDEB0(("processone: processing: [%s] %s\n",
|
||||
displayableBytes(stp->st_size).c_str(), fn.c_str()));
|
||||
|
||||
FileInterner interner(fn, stp, config, tmpdir, FileInterner::FIF_none);
|
||||
FileInterner interner(fn, stp, config, FileInterner::FIF_none);
|
||||
if (!interner.ok()) {
|
||||
// no indexing whatsoever in this case. This typically means that
|
||||
// indexallfilenames is not set
|
||||
|
|
|
@ -59,7 +59,7 @@ class FsIndexer : public FsTreeWalkerCB {
|
|||
/**
|
||||
* Top level file system tree index method for updating a given database.
|
||||
*
|
||||
* We create the temporary directory, open the database,
|
||||
* We open the database,
|
||||
* then call a file system walk for each top-level directory.
|
||||
*/
|
||||
bool index();
|
||||
|
@ -88,7 +88,6 @@ class FsIndexer : public FsTreeWalkerCB {
|
|||
FsTreeWalker m_walker;
|
||||
RclConfig *m_config;
|
||||
Rcl::Db *m_db;
|
||||
TempDir m_tmpdir;
|
||||
string m_reason;
|
||||
DbIxStatusUpdater *m_updater;
|
||||
std::vector<std::string> m_tdl;
|
||||
|
@ -127,7 +126,7 @@ class FsIndexer : public FsTreeWalkerCB {
|
|||
Rcl::Doc& doc);
|
||||
string getDbDir() {return m_config->getDbDir();}
|
||||
FsTreeWalker::Status
|
||||
processonefile(RclConfig *config, TempDir& tmpdir, const string &fn,
|
||||
processonefile(RclConfig *config, const string &fn,
|
||||
const struct stat *, const map<string,string>& localfields,
|
||||
const vector<MDReaper>& mdreapers);
|
||||
};
|
||||
|
|
|
@ -151,60 +151,6 @@ string FileInterner::getLastIpathElt(const string& ipath)
|
|||
}
|
||||
}
|
||||
|
||||
// Uncompress input file into a temporary one, by executing the appropriate
|
||||
// script.
|
||||
static bool uncompressfile(RclConfig *conf, const string& ifn,
|
||||
const vector<string>& cmdv, TempDir& tdir,
|
||||
string& tfile)
|
||||
{
|
||||
// Make sure tmp dir is empty. we guarantee this to filters
|
||||
if (!tdir.ok() || !tdir.wipe()) {
|
||||
LOGERR(("uncompressfile: can't clear temp dir %s\n", tdir.dirname()));
|
||||
return false;
|
||||
}
|
||||
string cmd = cmdv.front();
|
||||
|
||||
// Substitute file name and temp dir in command elements
|
||||
vector<string>::const_iterator it = cmdv.begin();
|
||||
++it;
|
||||
vector<string> args;
|
||||
map<char, string> subs;
|
||||
subs['f'] = ifn;
|
||||
subs['t'] = tdir.dirname();
|
||||
for (; it != cmdv.end(); it++) {
|
||||
string ns;
|
||||
pcSubst(*it, ns, subs);
|
||||
args.push_back(ns);
|
||||
}
|
||||
|
||||
// Execute command and retrieve output file name, check that it exists
|
||||
ExecCmd ex;
|
||||
int status = ex.doexec(cmd, args, 0, &tfile);
|
||||
if (status || tfile.empty()) {
|
||||
LOGERR(("uncompressfile: doexec: failed for [%s] status 0x%x\n",
|
||||
ifn.c_str(), status));
|
||||
if (!tdir.wipe()) {
|
||||
LOGERR(("uncompressfile: wipedir failed\n"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (tfile[tfile.length() - 1] == '\n')
|
||||
tfile.erase(tfile.length() - 1, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Delete temporary uncompressed file
|
||||
void FileInterner::tmpcleanup()
|
||||
{
|
||||
if (m_tfile.empty())
|
||||
return;
|
||||
if (unlink(m_tfile.c_str()) < 0) {
|
||||
LOGERR(("FileInterner::tmpcleanup: unlink(%s) errno %d\n",
|
||||
m_tfile.c_str(), errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Constructor: identify the input file, possibly create an
|
||||
// uncompressed temporary copy, and create the top filter for the
|
||||
// uncompressed file type.
|
||||
|
@ -213,9 +159,8 @@ void FileInterner::tmpcleanup()
|
|||
// processed by the first call to internfile().
|
||||
// Split into "constructor calls init()" to allow use from other constructor
|
||||
FileInterner::FileInterner(const string &fn, const struct stat *stp,
|
||||
RclConfig *cnf,
|
||||
TempDir& td, int flags, const string *imime)
|
||||
: m_tdir(td), m_ok(false), m_missingdatap(0)
|
||||
RclConfig *cnf, int flags, const string *imime)
|
||||
: m_ok(false), m_missingdatap(0), m_uncomp((flags & FIF_forPreview) != 0)
|
||||
{
|
||||
LOGDEB0(("FileInterner::FileInterner(fn=%s)\n", fn.c_str()));
|
||||
if (fn.empty()) {
|
||||
|
@ -285,11 +230,11 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
|
|||
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)) {
|
||||
if (!m_uncomp.uncompressfile(m_fn, ucmd, m_tfile)) {
|
||||
return;
|
||||
}
|
||||
LOGDEB1(("FileInterner:: after ucomp: m_tdir %s, tfile %s\n",
|
||||
m_tdir.dirname(), m_tfile.c_str()));
|
||||
LOGDEB1(("FileInterner:: after ucomp: tfile %s\n",
|
||||
m_tfile.c_str()));
|
||||
m_fn = m_tfile;
|
||||
// Stat the uncompressed file, mainly to get the size
|
||||
struct stat ucstat;
|
||||
|
@ -352,8 +297,8 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
|
|||
|
||||
// Setup from memory data (ie: out of the web cache). imime needs to be set.
|
||||
FileInterner::FileInterner(const string &data, RclConfig *cnf,
|
||||
TempDir& td, int flags, const string& imime)
|
||||
: m_tdir(td), m_ok(false), m_missingdatap(0)
|
||||
int flags, const string& imime)
|
||||
: m_ok(false), m_missingdatap(0), m_uncomp((flags & FIF_forPreview) != 0)
|
||||
{
|
||||
LOGDEB0(("FileInterner::FileInterner(data)\n"));
|
||||
initcommon(cnf, flags);
|
||||
|
@ -416,9 +361,8 @@ void FileInterner::initcommon(RclConfig *cnf, int flags)
|
|||
m_targetMType = cstr_textplain;
|
||||
}
|
||||
|
||||
FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf,
|
||||
TempDir& td, int flags)
|
||||
: m_tdir(td), m_ok(false), m_missingdatap(0)
|
||||
FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, int flags)
|
||||
: m_ok(false), m_missingdatap(0), m_uncomp(((flags & FIF_forPreview) != 0))
|
||||
{
|
||||
LOGDEB0(("FileInterner::FileInterner(idoc)\n"));
|
||||
initcommon(cnf, flags);
|
||||
|
@ -462,7 +406,6 @@ bool FileInterner::makesig(RclConfig *cnf, const Rcl::Doc& idoc, string& sig)
|
|||
|
||||
FileInterner::~FileInterner()
|
||||
{
|
||||
tmpcleanup();
|
||||
for (vector<Dijon::Filter*>::iterator it = m_handlers.begin();
|
||||
it != m_handlers.end(); it++) {
|
||||
returnMimeHandler(*it);
|
||||
|
@ -1012,12 +955,10 @@ bool FileInterner::idocToFile(TempFile& otemp, const string& tofile,
|
|||
LOGDEB(("FileInterner::idocToFile\n"));
|
||||
idoc.dump();
|
||||
|
||||
TempDir tmpdir;
|
||||
|
||||
// We set FIF_forPreview for consistency with the previous version
|
||||
// which determined this by looking at mtype!=null. Probably
|
||||
// doesn't change anything in this case.
|
||||
FileInterner interner(idoc, cnf, tmpdir, FIF_forPreview);
|
||||
FileInterner interner(idoc, cnf, FIF_forPreview);
|
||||
interner.setTargetMType(idoc.mimetype);
|
||||
return interner.interntofile(otemp, tofile, idoc.ipath, idoc.mimetype);
|
||||
}
|
||||
|
@ -1102,6 +1043,7 @@ bool FileInterner::isCompressed(const string& fn, RclConfig *cnf)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Static.
|
||||
bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
|
||||
RclConfig *cnf, const Rcl::Doc& doc)
|
||||
{
|
||||
|
@ -1131,16 +1073,16 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
|
|||
fn.c_str(), maxkbs));
|
||||
return false;
|
||||
}
|
||||
TempDir tmpdir;
|
||||
temp =
|
||||
TempFile(new TempFileInternal(cnf->getSuffixFromMimeType(doc.mimetype)));
|
||||
if (!tmpdir.ok() || !temp->ok()) {
|
||||
LOGERR(("FileInterner: cant create temporary file/dir"));
|
||||
if (!temp->ok()) {
|
||||
LOGERR(("FileInterner: cant create temporary file"));
|
||||
return false;
|
||||
}
|
||||
|
||||
Uncomp uncomp;
|
||||
string uncomped;
|
||||
if (!uncompressfile(cnf, fn, ucmd, tmpdir, uncomped)) {
|
||||
if (!uncomp.uncompressfile(fn, ucmd, uncomped)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1233,8 +1175,7 @@ int main(int argc, char **argv)
|
|||
perror("stat");
|
||||
exit(1);
|
||||
}
|
||||
TempDir tmp;
|
||||
FileInterner interner(fn, &st, config, tmp, 0);
|
||||
FileInterner interner(fn, &st, config, 0);
|
||||
Rcl::Doc doc;
|
||||
FileInterner::Status status = interner.internfile(doc, ipath);
|
||||
switch (status) {
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
#ifndef _INTERNFILE_H_INCLUDED_
|
||||
#define _INTERNFILE_H_INCLUDED_
|
||||
// The class changes according to RCL_USE_XATTR
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -27,8 +29,7 @@ using std::map;
|
|||
using std::set;
|
||||
|
||||
#include "Filter.h"
|
||||
// The class changes according to RCL_USE_XATTR
|
||||
#include "autoconfig.h"
|
||||
#include "uncomp.h"
|
||||
#include "pathut.h"
|
||||
|
||||
class RclConfig;
|
||||
|
@ -114,15 +115,14 @@ class FileInterner {
|
|||
* mime type for the uncompressed version.
|
||||
*/
|
||||
FileInterner(const string &fn, const struct stat *stp,
|
||||
RclConfig *cnf, TempDir &td, int flags,
|
||||
const string *mtype = 0);
|
||||
RclConfig *cnf, int flags, const string *mtype = 0);
|
||||
|
||||
/**
|
||||
* Alternate constructor for the case where the data is in memory.
|
||||
* This is mainly for data extracted from the web cache. The mime type
|
||||
* must be set, input must be already uncompressed.
|
||||
*/
|
||||
FileInterner(const string &data, RclConfig *cnf, TempDir &td,
|
||||
FileInterner(const string &data, RclConfig *cnf,
|
||||
int flags, const string& mtype);
|
||||
|
||||
/**
|
||||
|
@ -135,8 +135,7 @@ class FileInterner {
|
|||
* ipath...) to retrieve the file or a file reference, which we
|
||||
* then process normally.
|
||||
*/
|
||||
FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, TempDir &td,
|
||||
int flags);
|
||||
FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, int flags);
|
||||
|
||||
~FileInterner();
|
||||
|
||||
|
@ -251,8 +250,6 @@ class FileInterner {
|
|||
TempFile m_imgtmp; // Possible reference to an image temp file
|
||||
string m_targetMType;
|
||||
string m_reachedMType; // target or text/plain
|
||||
// m_tdir and m_tfile are used only for decompressing input file if needed
|
||||
TempDir &m_tdir;
|
||||
string m_tfile;
|
||||
bool m_ok; // Set after construction if ok
|
||||
#ifdef RCL_USE_XATTR
|
||||
|
@ -273,6 +270,8 @@ class FileInterner {
|
|||
string m_reason;
|
||||
FIMissingStore *m_missingdatap;
|
||||
|
||||
Uncomp m_uncomp;
|
||||
|
||||
// Pseudo-constructors
|
||||
void init(const string &fn, const struct stat *stp,
|
||||
RclConfig *cnf, int flags, const string *mtype = 0);
|
||||
|
@ -280,7 +279,6 @@ class FileInterner {
|
|||
const string& mtype);
|
||||
void initcommon(RclConfig *cnf, int flags);
|
||||
|
||||
void tmpcleanup();
|
||||
bool dijontorcl(Rcl::Doc&);
|
||||
void collectIpathAndMT(Rcl::Doc&) const;
|
||||
TempFile dataToTempFile(const string& data, const string& mt);
|
||||
|
|
104
src/internfile/uncomp.cpp
Normal file
104
src/internfile/uncomp.cpp
Normal file
|
@ -0,0 +1,104 @@
|
|||
/* Copyright (C) 2013 J.F.Dockes
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
using std::map;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
#include "uncomp.h"
|
||||
#include "debuglog.h"
|
||||
#include "smallut.h"
|
||||
#include "execmd.h"
|
||||
|
||||
Uncomp::UncompCache Uncomp::o_cache;
|
||||
|
||||
bool Uncomp::uncompressfile(const string& ifn,
|
||||
const vector<string>& cmdv, string& tfile)
|
||||
{
|
||||
if (m_docache) {
|
||||
PTMutexLocker lock(o_cache.m_lock);
|
||||
if (!o_cache.m_srcpath.compare(ifn)) {
|
||||
m_dir = o_cache.m_dir;
|
||||
m_tfile = tfile = o_cache.m_tfile;
|
||||
m_srcpath = ifn;
|
||||
o_cache.m_dir = 0;
|
||||
o_cache.m_srcpath.clear();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
m_srcpath.clear();
|
||||
m_tfile.clear();
|
||||
if (m_dir == 0) {
|
||||
m_dir = new TempDir;
|
||||
}
|
||||
// Make sure tmp dir is empty. we guarantee this to filters
|
||||
if (!m_dir || !m_dir->ok() || !m_dir->wipe()) {
|
||||
LOGERR(("uncompressfile: can't clear temp dir %s\n", m_dir->dirname()));
|
||||
return false;
|
||||
}
|
||||
string cmd = cmdv.front();
|
||||
|
||||
// Substitute file name and temp dir in command elements
|
||||
vector<string>::const_iterator it = cmdv.begin();
|
||||
++it;
|
||||
vector<string> args;
|
||||
map<char, string> subs;
|
||||
subs['f'] = ifn;
|
||||
subs['t'] = m_dir->dirname();
|
||||
for (; it != cmdv.end(); it++) {
|
||||
string ns;
|
||||
pcSubst(*it, ns, subs);
|
||||
args.push_back(ns);
|
||||
}
|
||||
|
||||
// Execute command and retrieve output file name, check that it exists
|
||||
ExecCmd ex;
|
||||
int status = ex.doexec(cmd, args, 0, &tfile);
|
||||
if (status || tfile.empty()) {
|
||||
LOGERR(("uncompressfile: doexec: failed for [%s] status 0x%x\n",
|
||||
ifn.c_str(), status));
|
||||
if (!m_dir->wipe()) {
|
||||
LOGERR(("uncompressfile: wipedir failed\n"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (tfile[tfile.length() - 1] == '\n')
|
||||
tfile.erase(tfile.length() - 1, 1);
|
||||
m_tfile = tfile;
|
||||
m_srcpath = ifn;
|
||||
return true;
|
||||
}
|
||||
|
||||
Uncomp::~Uncomp()
|
||||
{
|
||||
if (m_docache) {
|
||||
PTMutexLocker lock(o_cache.m_lock);
|
||||
delete o_cache.m_dir;
|
||||
o_cache.m_dir = m_dir;
|
||||
o_cache.m_tfile = m_tfile;
|
||||
o_cache.m_srcpath = m_srcpath;
|
||||
} else {
|
||||
delete m_dir;
|
||||
}
|
||||
}
|
||||
|
68
src/internfile/uncomp.h
Normal file
68
src/internfile/uncomp.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* Copyright (C) 2013 J.F.Dockes
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _UNCOMP_H_INCLUDED_
|
||||
#define _UNCOMP_H_INCLUDED_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "pathut.h"
|
||||
#include "ptmutex.h"
|
||||
|
||||
/// Uncompression script interface.
|
||||
class Uncomp {
|
||||
public:
|
||||
Uncomp(bool docache = false)
|
||||
: m_dir(0), m_docache(docache)
|
||||
{
|
||||
}
|
||||
~Uncomp();
|
||||
|
||||
/** Uncompress the input file into a temporary one, by executing the
|
||||
* script given as input.
|
||||
* Return the path to the uncompressed file (which is inside a
|
||||
* temporary directory).
|
||||
*/
|
||||
bool uncompressfile(const std::string& ifn,
|
||||
const std::vector<std::string>& cmdv,
|
||||
std::string& tfile);
|
||||
|
||||
private:
|
||||
TempDir *m_dir;
|
||||
string m_tfile;
|
||||
string m_srcpath;
|
||||
bool m_docache;
|
||||
|
||||
class UncompCache {
|
||||
public:
|
||||
UncompCache()
|
||||
: m_dir(0)
|
||||
{
|
||||
}
|
||||
~UncompCache()
|
||||
{
|
||||
delete m_dir;
|
||||
}
|
||||
PTMutexInit m_lock;
|
||||
TempDir *m_dir;
|
||||
string m_tfile;
|
||||
string m_srcpath;
|
||||
};
|
||||
static UncompCache o_cache;
|
||||
};
|
||||
|
||||
#endif /* _UNCOMP_H_INCLUDED_ */
|
|
@ -236,14 +236,7 @@ public:
|
|||
|
||||
void RecollProtocol::showPreview(const Rcl::Doc& idoc)
|
||||
{
|
||||
TempDir tmpdir;
|
||||
if (!tmpdir.ok()) {
|
||||
error(KIO::ERR_SLAVE_DEFINED, "Cannot create temp directory");
|
||||
return;
|
||||
}
|
||||
|
||||
FileInterner interner(idoc, o_rclconfig, tmpdir,
|
||||
FileInterner::FIF_forPreview);
|
||||
FileInterner interner(idoc, o_rclconfig, FileInterner::FIF_forPreview);
|
||||
Rcl::Doc fdoc;
|
||||
string ipath = idoc.ipath;
|
||||
if (!interner.internfile(fdoc, ipath)) {
|
||||
|
|
|
@ -8,8 +8,8 @@ LIBS = librecoll.a $(LIBRECOLL)
|
|||
|
||||
all: $(LIBS)
|
||||
|
||||
OBJS = rclaspell.o beaglequeuecache.o cstr.o rclconfig.o rclinit.o textsplit.o unacpp.o beaglequeue.o bglfetcher.o fetcher.o fsfetcher.o fsindexer.o indexer.o mimetype.o subtreelist.o htmlparse.o internfile.o mh_exec.o mh_execm.o mh_html.o mh_mail.o mh_mbox.o mh_text.o mimehandler.o myhtmlparse.o txtdcode.o docseq.o docseqdb.o docseqhist.o filtseq.o dynconf.o plaintorich.o recollq.o reslistpager.o sortseq.o wasastringtoquery.o wasatorcl.o daterange.o expansiondbs.o rclabstract.o rcldb.o rcldoc.o rclquery.o rclterms.o searchdata.o searchdataxml.o stemdb.o stoplist.o synfamily.o unac.o base64.o circache.o closefrom.o conftree.o copyfile.o debuglog.o ecrontab.o execmd.o fstreewalk.o idfile.o fileudi.o md5.o mimeparse.o netcon.o pathut.o pxattr.o rclionice.o readfile.o smallut.o strmatcher.o transcode.o wipedir.o x11mon.o mime-parsefull.o mime-parseonlyheader.o mime-printbody.o mime.o convert.o iodevice.o iofactory.o
|
||||
DEPS = rclaspell.dep.stamp beaglequeuecache.dep.stamp cstr.dep.stamp rclconfig.dep.stamp rclinit.dep.stamp textsplit.dep.stamp unacpp.dep.stamp beaglequeue.dep.stamp bglfetcher.dep.stamp fetcher.dep.stamp fsfetcher.dep.stamp fsindexer.dep.stamp indexer.dep.stamp mimetype.dep.stamp subtreelist.dep.stamp htmlparse.dep.stamp internfile.dep.stamp mh_exec.dep.stamp mh_execm.dep.stamp mh_html.dep.stamp mh_mail.dep.stamp mh_mbox.dep.stamp mh_text.dep.stamp mimehandler.dep.stamp myhtmlparse.dep.stamp txtdcode.dep.stamp docseq.dep.stamp docseqdb.dep.stamp docseqhist.dep.stamp filtseq.dep.stamp dynconf.dep.stamp plaintorich.dep.stamp recollq.dep.stamp reslistpager.dep.stamp sortseq.dep.stamp wasastringtoquery.dep.stamp wasatorcl.dep.stamp daterange.dep.stamp expansiondbs.dep.stamp rclabstract.dep.stamp rcldb.dep.stamp rcldoc.dep.stamp rclquery.dep.stamp rclterms.dep.stamp searchdata.dep.stamp searchdataxml.dep.stamp stemdb.dep.stamp stoplist.dep.stamp synfamily.dep.stamp unac.dep.stamp base64.dep.stamp circache.dep.stamp closefrom.dep.stamp conftree.dep.stamp copyfile.dep.stamp debuglog.dep.stamp ecrontab.dep.stamp execmd.dep.stamp fstreewalk.dep.stamp idfile.dep.stamp fileudi.dep.stamp md5.dep.stamp mimeparse.dep.stamp netcon.dep.stamp pathut.dep.stamp pxattr.dep.stamp rclionice.dep.stamp readfile.dep.stamp smallut.dep.stamp strmatcher.dep.stamp transcode.dep.stamp wipedir.dep.stamp x11mon.dep.stamp mime-parsefull.dep.stamp mime-parseonlyheader.dep.stamp mime-printbody.dep.stamp mime.dep.stamp convert.dep.stamp iodevice.dep.stamp iofactory.dep.stamp
|
||||
OBJS = rclaspell.o beaglequeuecache.o cstr.o rclconfig.o rclinit.o textsplit.o unacpp.o beaglequeue.o bglfetcher.o fetcher.o fsfetcher.o fsindexer.o indexer.o mimetype.o subtreelist.o htmlparse.o internfile.o mh_exec.o mh_execm.o mh_html.o mh_mail.o mh_mbox.o mh_text.o mimehandler.o myhtmlparse.o txtdcode.o uncomp.o docseq.o docseqdb.o docseqhist.o filtseq.o dynconf.o plaintorich.o recollq.o reslistpager.o sortseq.o wasastringtoquery.o wasatorcl.o daterange.o expansiondbs.o rclabstract.o rcldb.o rcldoc.o rclquery.o rclterms.o searchdata.o searchdataxml.o stemdb.o stoplist.o synfamily.o unac.o base64.o circache.o closefrom.o conftree.o copyfile.o debuglog.o ecrontab.o execmd.o fstreewalk.o idfile.o fileudi.o md5.o mimeparse.o netcon.o pathut.o pxattr.o rclionice.o readfile.o smallut.o strmatcher.o transcode.o wipedir.o x11mon.o mime-parsefull.o mime-parseonlyheader.o mime-printbody.o mime.o convert.o iodevice.o iofactory.o
|
||||
DEPS = rclaspell.dep.stamp beaglequeuecache.dep.stamp cstr.dep.stamp rclconfig.dep.stamp rclinit.dep.stamp textsplit.dep.stamp unacpp.dep.stamp beaglequeue.dep.stamp bglfetcher.dep.stamp fetcher.dep.stamp fsfetcher.dep.stamp fsindexer.dep.stamp indexer.dep.stamp mimetype.dep.stamp subtreelist.dep.stamp htmlparse.dep.stamp internfile.dep.stamp mh_exec.dep.stamp mh_execm.dep.stamp mh_html.dep.stamp mh_mail.dep.stamp mh_mbox.dep.stamp mh_text.dep.stamp mimehandler.dep.stamp myhtmlparse.dep.stamp txtdcode.dep.stamp uncomp.dep.stamp docseq.dep.stamp docseqdb.dep.stamp docseqhist.dep.stamp filtseq.dep.stamp dynconf.dep.stamp plaintorich.dep.stamp recollq.dep.stamp reslistpager.dep.stamp sortseq.dep.stamp wasastringtoquery.dep.stamp wasatorcl.dep.stamp daterange.dep.stamp expansiondbs.dep.stamp rclabstract.dep.stamp rcldb.dep.stamp rcldoc.dep.stamp rclquery.dep.stamp rclterms.dep.stamp searchdata.dep.stamp searchdataxml.dep.stamp stemdb.dep.stamp stoplist.dep.stamp synfamily.dep.stamp unac.dep.stamp base64.dep.stamp circache.dep.stamp closefrom.dep.stamp conftree.dep.stamp copyfile.dep.stamp debuglog.dep.stamp ecrontab.dep.stamp execmd.dep.stamp fstreewalk.dep.stamp idfile.dep.stamp fileudi.dep.stamp md5.dep.stamp mimeparse.dep.stamp netcon.dep.stamp pathut.dep.stamp pxattr.dep.stamp rclionice.dep.stamp readfile.dep.stamp smallut.dep.stamp strmatcher.dep.stamp transcode.dep.stamp wipedir.dep.stamp x11mon.dep.stamp mime-parsefull.dep.stamp mime-parseonlyheader.dep.stamp mime-printbody.dep.stamp mime.dep.stamp convert.dep.stamp iodevice.dep.stamp iofactory.dep.stamp
|
||||
|
||||
librecoll.a : $(DEPS) $(OBJS)
|
||||
ar ru librecoll.a $(OBJS)
|
||||
|
@ -75,6 +75,8 @@ myhtmlparse.o : ../internfile/myhtmlparse.cpp $(depth)/mk/localdefs
|
|||
$(CXX) $(ALL_CXXFLAGS) -c ../internfile/myhtmlparse.cpp
|
||||
txtdcode.o : ../internfile/txtdcode.cpp $(depth)/mk/localdefs
|
||||
$(CXX) $(ALL_CXXFLAGS) -c ../internfile/txtdcode.cpp
|
||||
uncomp.o : ../internfile/uncomp.cpp $(depth)/mk/localdefs
|
||||
$(CXX) $(ALL_CXXFLAGS) -c ../internfile/uncomp.cpp
|
||||
docseq.o : ../query/docseq.cpp $(depth)/mk/localdefs
|
||||
$(CXX) $(ALL_CXXFLAGS) -c ../query/docseq.cpp
|
||||
docseqdb.o : ../query/docseqdb.cpp $(depth)/mk/localdefs
|
||||
|
@ -267,6 +269,9 @@ myhtmlparse.dep.stamp : ../internfile/myhtmlparse.cpp $(depth)/mk/localdefs
|
|||
txtdcode.dep.stamp : ../internfile/txtdcode.cpp $(depth)/mk/localdefs
|
||||
$(CXX) -M $(ALL_CXXFLAGS) ../internfile/txtdcode.cpp > txtdcode.dep
|
||||
touch txtdcode.dep.stamp
|
||||
uncomp.dep.stamp : ../internfile/uncomp.cpp $(depth)/mk/localdefs
|
||||
$(CXX) -M $(ALL_CXXFLAGS) ../internfile/uncomp.cpp > uncomp.dep
|
||||
touch uncomp.dep.stamp
|
||||
docseq.dep.stamp : ../query/docseq.cpp $(depth)/mk/localdefs
|
||||
$(CXX) -M $(ALL_CXXFLAGS) ../query/docseq.cpp > docseq.dep
|
||||
touch docseq.dep.stamp
|
||||
|
@ -434,6 +439,7 @@ include mh_text.dep
|
|||
include mimehandler.dep
|
||||
include myhtmlparse.dep
|
||||
include txtdcode.dep
|
||||
include uncomp.dep
|
||||
include docseq.dep
|
||||
include docseqdb.dep
|
||||
include docseqhist.dep
|
||||
|
|
|
@ -31,6 +31,7 @@ ${depth}/internfile/mh_text.cpp \
|
|||
${depth}/internfile/mimehandler.cpp \
|
||||
${depth}/internfile/myhtmlparse.cpp \
|
||||
${depth}/internfile/txtdcode.cpp \
|
||||
${depth}/internfile/uncomp.cpp \
|
||||
${depth}/query/docseq.cpp \
|
||||
${depth}/query/docseqdb.cpp \
|
||||
${depth}/query/docseqhist.cpp \
|
||||
|
|
|
@ -43,7 +43,6 @@ typedef struct {
|
|||
PyObject_HEAD
|
||||
/* Type-specific fields go here. */
|
||||
FileInterner *xtr;
|
||||
TempDir *tmpdir;
|
||||
RclConfig *rclconfig;
|
||||
} rclx_ExtractorObject;
|
||||
|
||||
|
@ -52,7 +51,6 @@ Extractor_dealloc(rclx_ExtractorObject *self)
|
|||
{
|
||||
LOGDEB(("Extractor_dealloc\n"));
|
||||
delete self->xtr;
|
||||
delete self->tmpdir;
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
|
@ -65,7 +63,6 @@ Extractor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
if (self == 0)
|
||||
return 0;
|
||||
self->xtr = 0;
|
||||
self->tmpdir = 0;
|
||||
self->rclconfig = 0;
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
@ -81,13 +78,12 @@ Extractor_init(rclx_ExtractorObject *self, PyObject *args, PyObject *kwargs)
|
|||
recoll_DocType, &pdobj))
|
||||
return -1;
|
||||
recoll_DocObject *dobj = (recoll_DocObject *)pdobj;
|
||||
self->tmpdir = new TempDir;
|
||||
if (dobj->doc == 0) {
|
||||
PyErr_SetString(PyExc_AttributeError, "Null Doc ?");
|
||||
return -1;
|
||||
}
|
||||
self->rclconfig = dobj->rclconfig;
|
||||
self->xtr = new FileInterner(*dobj->doc, self->rclconfig, *self->tmpdir,
|
||||
self->xtr = new FileInterner(*dobj->doc, self->rclconfig,
|
||||
FileInterner::FIF_forPreview);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -715,12 +715,10 @@ class LoadThread : public QThread {
|
|||
int *statusp;
|
||||
Rcl::Doc& out;
|
||||
const Rcl::Doc& idoc;
|
||||
TempDir tmpdir;
|
||||
int loglevel;
|
||||
public:
|
||||
string missing;
|
||||
TempFile imgtmp;
|
||||
string tdirreason;
|
||||
|
||||
LoadThread(int *stp, Rcl::Doc& odoc, const Rcl::Doc& idc)
|
||||
: statusp(stp), out(odoc), idoc(idc)
|
||||
|
@ -731,15 +729,8 @@ class LoadThread : public QThread {
|
|||
}
|
||||
virtual void run() {
|
||||
DebugLog::getdbl()->setloglevel(loglevel);
|
||||
if (!tmpdir.ok()) {
|
||||
tdirreason = tmpdir.getreason();
|
||||
LOGERR(("Preview: %s\n", tdirreason.c_str()));
|
||||
*statusp = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
FileInterner interner(idoc, theconfig, tmpdir,
|
||||
FileInterner::FIF_forPreview);
|
||||
FileInterner interner(idoc, theconfig, FileInterner::FIF_forPreview);
|
||||
FIMissingStore mst;
|
||||
interner.setMissingStore(&mst);
|
||||
// Even when previewHtml is set, we don't set the interner's
|
||||
|
@ -859,11 +850,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
|
|||
return false;
|
||||
if (status != 0) {
|
||||
QString explain;
|
||||
if (!lthr.tdirreason.empty()) {
|
||||
explain = tr("Cannot create temporary directory: ") +
|
||||
QString::fromLocal8Bit(lthr.tdirreason.c_str());
|
||||
QMessageBox::critical(0, "Recoll", explain);
|
||||
} else if (!lthr.missing.empty()) {
|
||||
if (!lthr.missing.empty()) {
|
||||
explain = QString::fromAscii("<br>") +
|
||||
tr("Missing helper program: ") +
|
||||
QString::fromLocal8Bit(lthr.missing.c_str());
|
||||
|
|
|
@ -45,10 +45,9 @@ using namespace std;
|
|||
#include "smallut.h"
|
||||
#include "base64.h"
|
||||
|
||||
bool dump_contents(RclConfig *rclconfig, TempDir& tmpdir, Rcl::Doc& idoc)
|
||||
bool dump_contents(RclConfig *rclconfig, Rcl::Doc& idoc)
|
||||
{
|
||||
FileInterner interner(idoc, rclconfig, tmpdir,
|
||||
FileInterner::FIF_forPreview);
|
||||
FileInterner interner(idoc, rclconfig, FileInterner::FIF_forPreview);
|
||||
Rcl::Doc fdoc;
|
||||
string ipath = idoc.ipath;
|
||||
if (interner.internfile(fdoc, ipath)) {
|
||||
|
@ -393,13 +392,7 @@ endopts:
|
|||
}
|
||||
}
|
||||
if (op_flags & OPT_d) {
|
||||
static TempDir tmpdir;
|
||||
if (!tmpdir.ok()) {
|
||||
cerr << "Can't create temporary directory: " <<
|
||||
tmpdir.getreason() << endl;
|
||||
return(1);
|
||||
}
|
||||
dump_contents(rclconfig, tmpdir, doc);
|
||||
dump_contents(rclconfig, doc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue