Switch to unified view

a/src/rcldb/rcldb.cpp b/src/rcldb/rcldb.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.81 2006-10-22 14:47:13 dockes Exp $ (C) 2004 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.82 2006-10-22 15:54:23 dockes Exp $ (C) 2004 J.F.Dockes";
3
#endif
3
#endif
4
/*
4
/*
5
 *   This program is free software; you can redistribute it and/or modify
5
 *   This program is free software; you can redistribute it and/or modify
6
 *   it under the terms of the GNU General Public License as published by
6
 *   it under the terms of the GNU General Public License as published by
7
 *   the Free Software Foundation; either version 2 of the License, or
7
 *   the Free Software Foundation; either version 2 of the License, or
...
...
678
}
678
}
679
679
680
// Test if given filename has changed since last indexed:
680
// Test if given filename has changed since last indexed:
681
bool Db::needUpdate(const string &filename, const struct stat *stp)
681
bool Db::needUpdate(const string &filename, const struct stat *stp)
682
{
682
{
683
    //    Chrono chron;
683
    if (m_ndb == 0)
684
    if (m_ndb == 0)
684
    return false;
685
    return false;
685
686
686
    string hash;
687
    string hash;
687
    pathHash(filename, hash, PATHHASHLEN);
688
    pathHash(filename, hash, PATHHASHLEN);
...
...
693
    // fmtime field which will be identical for all docs inside a
694
    // fmtime field which will be identical for all docs inside a
694
    // multi-document file (we currently always reindex all if the
695
    // multi-document file (we currently always reindex all if the
695
    // file changed)
696
    // file changed)
696
    Xapian::PostingIterator doc;
697
    Xapian::PostingIterator doc;
697
    try {
698
    try {
698
  if (!m_ndb->wdb.term_exists(pterm)) {
699
  // Check the date using the Pterm doc or pseudo-doc
700
  Xapian::PostingIterator docid = m_ndb->wdb.postlist_begin(pterm);
701
  if (docid == m_ndb->wdb.postlist_end(pterm)) {
699
        // If no document exist with this path, we do need update
702
        // If no document exist with this path, we do need update
700
        LOGDEB2(("Db::needUpdate: no such path: [%s]\n", pterm.c_str()));
703
        LOGDEB2(("Db::needUpdate: no such path: [%s]\n", pterm.c_str()));
701
        return true;
704
        return true;
702
    }
705
    }
703
  // Check the date using the Pterm doc or pseudo-doc
704
  Xapian::PostingIterator docid = m_ndb->wdb.postlist_begin(pterm);
705
    Xapian::Document doc = m_ndb->wdb.get_document(*docid);
706
    Xapian::Document doc = m_ndb->wdb.get_document(*docid);
706
    string data = doc.get_data();
707
    string data = doc.get_data();
707
    const char *cp = strstr(data.c_str(), "fmtime=");
708
    const char *cp = strstr(data.c_str(), "fmtime=");
708
    if (cp) {
709
    if (cp) {
709
        cp += 7;
710
        cp += 7;
...
...
738
        if (*it < m_ndb->updated.size()) {
739
        if (*it < m_ndb->updated.size()) {
739
        LOGDEB2(("Db::needUpdate: set flag for docid %d\n", *it));
740
        LOGDEB2(("Db::needUpdate: set flag for docid %d\n", *it));
740
        m_ndb->updated[*it] = true;
741
        m_ndb->updated[*it] = true;
741
        }
742
        }
742
    }
743
    }
744
  //  LOGDEB(("Db::needUpdate: used %d mS\n", chron.millis()));
743
    return false;
745
    return false;
744
    } catch (const Xapian::Error &e) {
746
    } catch (const Xapian::Error &e) {
745
    ermsg = e.get_msg().c_str();
747
    ermsg = e.get_msg().c_str();
746
    } catch (...) {
748
    } catch (...) {
747
    ermsg= "Unknown error";
749
    ermsg= "Unknown error";