simplify needUpdate test
This commit is contained in:
parent
4e0d1e2483
commit
20fb46be1d
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.81 2006-10-22 14:47:13 dockes Exp $ (C) 2004 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.82 2006-10-22 15:54:23 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -680,6 +680,7 @@ bool Db::add(const string &fn, const Doc &idoc,
|
|||||||
// Test if given filename has changed since last indexed:
|
// Test if given filename has changed since last indexed:
|
||||||
bool Db::needUpdate(const string &filename, const struct stat *stp)
|
bool Db::needUpdate(const string &filename, const struct stat *stp)
|
||||||
{
|
{
|
||||||
|
// Chrono chron;
|
||||||
if (m_ndb == 0)
|
if (m_ndb == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -695,13 +696,13 @@ bool Db::needUpdate(const string &filename, const struct stat *stp)
|
|||||||
// file changed)
|
// file changed)
|
||||||
Xapian::PostingIterator doc;
|
Xapian::PostingIterator doc;
|
||||||
try {
|
try {
|
||||||
if (!m_ndb->wdb.term_exists(pterm)) {
|
// Check the date using the Pterm doc or pseudo-doc
|
||||||
|
Xapian::PostingIterator docid = m_ndb->wdb.postlist_begin(pterm);
|
||||||
|
if (docid == m_ndb->wdb.postlist_end(pterm)) {
|
||||||
// If no document exist with this path, we do need update
|
// If no document exist with this path, we do need update
|
||||||
LOGDEB2(("Db::needUpdate: no such path: [%s]\n", pterm.c_str()));
|
LOGDEB2(("Db::needUpdate: no such path: [%s]\n", pterm.c_str()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check the date using the Pterm doc or pseudo-doc
|
|
||||||
Xapian::PostingIterator docid = m_ndb->wdb.postlist_begin(pterm);
|
|
||||||
Xapian::Document doc = m_ndb->wdb.get_document(*docid);
|
Xapian::Document doc = m_ndb->wdb.get_document(*docid);
|
||||||
string data = doc.get_data();
|
string data = doc.get_data();
|
||||||
const char *cp = strstr(data.c_str(), "fmtime=");
|
const char *cp = strstr(data.c_str(), "fmtime=");
|
||||||
@ -740,6 +741,7 @@ bool Db::needUpdate(const string &filename, const struct stat *stp)
|
|||||||
m_ndb->updated[*it] = true;
|
m_ndb->updated[*it] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// LOGDEB(("Db::needUpdate: used %d mS\n", chron.millis()));
|
||||||
return false;
|
return false;
|
||||||
} catch (const Xapian::Error &e) {
|
} catch (const Xapian::Error &e) {
|
||||||
ermsg = e.get_msg().c_str();
|
ermsg = e.get_msg().c_str();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user