GUI: perform up to date check before previewing a subdoc. This is for example to avoid showing the wrong message if a mail folder has been compacted
This commit is contained in:
parent
036937e8bf
commit
516863b5d6
@ -282,7 +282,7 @@ void FsIndexer::setlocalfields(Rcl::Doc& doc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void makesig(const struct stat *stp, string& out)
|
void FsIndexer::makesig(const struct stat *stp, string& out)
|
||||||
{
|
{
|
||||||
char cbuf[100];
|
char cbuf[100];
|
||||||
sprintf(cbuf, OFFTPC "%ld", stp->st_size, (long)stp->RCL_STTIME);
|
sprintf(cbuf, OFFTPC "%ld", stp->st_size, (long)stp->RCL_STTIME);
|
||||||
|
|||||||
@ -24,10 +24,10 @@ using std::list;
|
|||||||
|
|
||||||
#include "indexer.h"
|
#include "indexer.h"
|
||||||
#include "fstreewalk.h"
|
#include "fstreewalk.h"
|
||||||
#include "rcldb.h"
|
|
||||||
|
|
||||||
class DbIxStatusUpdater;
|
class DbIxStatusUpdater;
|
||||||
class FIMissingStore;
|
class FIMissingStore;
|
||||||
|
struct stat;
|
||||||
|
|
||||||
/** Index selected parts of the file system
|
/** Index selected parts of the file system
|
||||||
|
|
||||||
@ -69,6 +69,9 @@ class FsIndexer : public FsTreeWalkerCB {
|
|||||||
FsTreeWalker::Status
|
FsTreeWalker::Status
|
||||||
processone(const string &fn, const struct stat *, FsTreeWalker::CbFlag);
|
processone(const string &fn, const struct stat *, FsTreeWalker::CbFlag);
|
||||||
|
|
||||||
|
/** Make signature for file up to date checks */
|
||||||
|
static void makesig(const struct stat *stp, string& out);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FsTreeWalker m_walker;
|
FsTreeWalker m_walker;
|
||||||
RclConfig *m_config;
|
RclConfig *m_config;
|
||||||
|
|||||||
@ -441,6 +441,42 @@ FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "fsindexer.h"
|
||||||
|
bool FileInterner::makesig(const Rcl::Doc& idoc, string& sig)
|
||||||
|
{
|
||||||
|
if (idoc.url.empty()) {
|
||||||
|
LOGERR(("FileInterner::makesig:: no url!\n"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
string backend;
|
||||||
|
idoc.getmeta(Rcl::Doc::keybcknd, &backend);
|
||||||
|
|
||||||
|
if (backend.empty() || !backend.compare("FS")) {
|
||||||
|
if (idoc.url.find(cstr_fileu) != 0) {
|
||||||
|
LOGERR(("FileInterner: FS backend and non fs url: [%s]\n",
|
||||||
|
idoc.url.c_str()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
string fn = idoc.url.substr(7, string::npos);
|
||||||
|
struct stat st;
|
||||||
|
if (stat(fn.c_str(), &st) < 0) {
|
||||||
|
LOGERR(("FileInterner:: cannot access document file: [%s]\n",
|
||||||
|
fn.c_str()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
FsIndexer::makesig(&st, sig);
|
||||||
|
return true;
|
||||||
|
} else if (!backend.compare("BGL")) {
|
||||||
|
// Bgl sigs are empty
|
||||||
|
sig.clear();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
LOGERR(("FileInterner:: unknown backend: [%s]\n", backend.c_str()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
FileInterner::~FileInterner()
|
FileInterner::~FileInterner()
|
||||||
{
|
{
|
||||||
tmpcleanup();
|
tmpcleanup();
|
||||||
|
|||||||
@ -121,6 +121,11 @@ class FileInterner {
|
|||||||
FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, TempDir &td,
|
FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, TempDir &td,
|
||||||
int flags);
|
int flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build sig for doc coming from rcldb. This is here because we know how
|
||||||
|
* to query the right backend */
|
||||||
|
static bool makesig(const Rcl::Doc& idoc, string& sig);
|
||||||
|
|
||||||
~FileInterner();
|
~FileInterner();
|
||||||
|
|
||||||
void setMissingStore(FIMissingStore *st)
|
void setMissingStore(FIMissingStore *st)
|
||||||
|
|||||||
@ -945,6 +945,29 @@ void RclMain::previewClosed(Preview *w)
|
|||||||
void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
|
void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
|
||||||
{
|
{
|
||||||
LOGDEB(("startPreview(%d, doc, %d)\n", docnum, mod));
|
LOGDEB(("startPreview(%d, doc, %d)\n", docnum, mod));
|
||||||
|
|
||||||
|
// Document up to date check. We do this only if ipath is not
|
||||||
|
// empty as this does not appear to be a serious issue for single
|
||||||
|
// docs (the main actual problem is displaying the wrong message
|
||||||
|
// from a compacted mail folder)
|
||||||
|
if (!doc.ipath.empty()) {
|
||||||
|
string udi, sig;
|
||||||
|
doc.getmeta(Rcl::Doc::keyudi, &udi);
|
||||||
|
FileInterner::makesig(doc, sig);
|
||||||
|
if (rcldb && !udi.empty()) {
|
||||||
|
if (rcldb->needUpdate(udi, sig)) {
|
||||||
|
fprintf(stderr, "AFTER UPDATE CHECK-1\n");
|
||||||
|
QMessageBox::warning(0, tr("Warning"),
|
||||||
|
tr("Index not up to date for this file. "
|
||||||
|
"Refusing to risk showing the wrong "
|
||||||
|
"data. Please run indexing"),
|
||||||
|
QMessageBox::Ok,
|
||||||
|
QMessageBox::NoButton);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mod & Qt::ShiftModifier) {
|
if (mod & Qt::ShiftModifier) {
|
||||||
// User wants new preview window
|
// User wants new preview window
|
||||||
curPreview = 0;
|
curPreview = 0;
|
||||||
|
|||||||
@ -1370,19 +1370,21 @@ bool Db::needUpdate(const string &udi, const string& sig)
|
|||||||
// Up to date.
|
// Up to date.
|
||||||
|
|
||||||
// Set the uptodate flag for doc / pseudo doc
|
// Set the uptodate flag for doc / pseudo doc
|
||||||
updated[*docid] = true;
|
if (m_mode != DbRO) {
|
||||||
|
updated[*docid] = true;
|
||||||
|
|
||||||
// Set the existence flag for all the subdocs (if any)
|
// Set the existence flag for all the subdocs (if any)
|
||||||
vector<Xapian::docid> docids;
|
vector<Xapian::docid> docids;
|
||||||
if (!m_ndb->subDocs(udi, docids)) {
|
if (!m_ndb->subDocs(udi, docids)) {
|
||||||
LOGERR(("Rcl::Db::needUpdate: can't get subdocs list\n"));
|
LOGERR(("Rcl::Db::needUpdate: can't get subdocs list\n"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (vector<Xapian::docid>::iterator it = docids.begin();
|
for (vector<Xapian::docid>::iterator it = docids.begin();
|
||||||
it != docids.end(); it++) {
|
it != docids.end(); it++) {
|
||||||
if (*it < updated.size()) {
|
if (*it < updated.size()) {
|
||||||
LOGDEB2(("Db::needUpdate: set flag for docid %d\n", *it));
|
LOGDEB2(("Db::needUpdate: set flag for docid %d\n", *it));
|
||||||
updated[*it] = true;
|
updated[*it] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user