--- a/src/index/webqueue.cpp
+++ b/src/index/webqueue.cpp
@@ -16,6 +16,8 @@
*/
#include "autoconfig.h"
+#include "webqueue.h"
+
#include <string.h>
#include <errno.h>
#include "safesysstat.h"
@@ -26,8 +28,7 @@
#include "rclutil.h"
#include "log.h"
#include "fstreewalk.h"
-#include "beaglequeue.h"
-#include "beaglequeuecache.h"
+#include "webstore.h"
#include "circache.h"
#include "smallut.h"
#include "fileudi.h"
@@ -44,12 +45,13 @@
using namespace std;
-// Beagle creates a file named .xxx (where xxx is the name for the main file
-// in the queue), to hold external metadata (http or created by Beagle).
-// This class reads the .xxx, dotfile, and turns it into an Rcl::Doc holder
-class BeagleDotFile {
+// The browser plugin creates a file named .xxx (where xxx is the name
+// for the main file in the queue), to hold external metadata (http or
+// created by the plugin). This class reads the .xxx, dotfile, and turns
+// it into an Rcl::Doc holder
+class WebQueueDotFile {
public:
- BeagleDotFile(RclConfig *conf, const string& fn)
+ WebQueueDotFile(RclConfig *conf, const string& fn)
: m_conf(conf), m_fn(fn)
{}
@@ -62,7 +64,7 @@
m_input.getline(cline, LL-1);
if (!m_input.good()) {
if (m_input.bad()) {
- LOGERR("beagleDotFileRead: input.bad()\n" );
+ LOGERR("WebQueueDotFileRead: input.bad()\n" );
}
return false;
}
@@ -72,18 +74,18 @@
ll--;
}
line.assign(cline, ll);
- LOGDEB2("BeagleDotFile:readLine: [" << (line) << "]\n" );
+ LOGDEB2("WebQueueDotFile:readLine: [" << (line) << "]\n" );
return true;
}
- // Process a beagle dot file and set interesting stuff in the doc
+ // Process a Web queue dot file and set interesting stuff in the doc
bool toDoc(Rcl::Doc& doc)
{
string line;
m_input.open(m_fn.c_str(), ios::in);
if (!m_input.good()) {
- LOGERR("BeagleDotFile: open failed for [" << (m_fn) << "]\n" );
+ LOGERR("WebQueueDotFile: open failed for [" << (m_fn) << "]\n" );
return false;
}
@@ -173,24 +175,24 @@
// Initialize. Compute paths and create a temporary directory that will be
// used by internfile()
-BeagleQueueIndexer::BeagleQueueIndexer(RclConfig *cnf, Rcl::Db *db,
+WebQueueIndexer::WebQueueIndexer(RclConfig *cnf, Rcl::Db *db,
DbIxStatusUpdater *updfunc)
: m_config(cnf), m_db(db), m_cache(0), m_updater(updfunc),
m_nocacheindex(false)
{
m_queuedir = m_config->getWebQueueDir();
path_catslash(m_queuedir);
- m_cache = new BeagleQueueCache(cnf);
-}
-
-BeagleQueueIndexer::~BeagleQueueIndexer()
-{
- LOGDEB("BeagleQueueIndexer::~\n" );
+ m_cache = new WebStore(cnf);
+}
+
+WebQueueIndexer::~WebQueueIndexer()
+{
+ LOGDEB("WebQueueIndexer::~\n" );
deleteZ(m_cache);
}
// Index document stored in the cache.
-bool BeagleQueueIndexer::indexFromCache(const string& udi)
+bool WebQueueIndexer::indexFromCache(const string& udi)
{
if (!m_db)
return false;
@@ -202,12 +204,12 @@
string hittype;
if (!m_cache || !m_cache->getFromCache(udi, dotdoc, data, &hittype)) {
- LOGERR("BeagleQueueIndexer::indexFromCache: cache failed\n" );
+ LOGERR("WebQueueIndexer::indexFromCache: cache failed\n" );
return false;
}
if (hittype.empty()) {
- LOGERR("BeagleIndexer::index: cc entry has no hit type\n" );
+ LOGERR("WebQueueIndexer::index: cc entry has no hit type\n" );
return false;
}
@@ -224,11 +226,11 @@
try {
fis = interner.internfile(doc);
} catch (CancelExcept) {
- LOGERR("BeagleQueueIndexer: interrupted\n" );
+ LOGERR("WebQueueIndexer: interrupted\n" );
return false;
}
if (fis != FileInterner::FIDone) {
- LOGERR("BeagleQueueIndexer: bad status from internfile\n" );
+ LOGERR("WebQueueIndexer: bad status from internfile\n" );
return false;
}
@@ -242,7 +244,7 @@
}
}
-void BeagleQueueIndexer::updstatus(const string& udi)
+void WebQueueIndexer::updstatus(const string& udi)
{
if (m_updater) {
++(m_updater->status.docsdone);
@@ -253,18 +255,18 @@
}
}
-bool BeagleQueueIndexer::index()
+bool WebQueueIndexer::index()
{
if (!m_db)
return false;
- LOGDEB("BeagleQueueIndexer::processqueue: [" << (m_queuedir) << "]\n" );
+ LOGDEB("WebQueueIndexer::processqueue: [" << (m_queuedir) << "]\n" );
m_config->setKeyDir(m_queuedir);
if (!path_makepath(m_queuedir, 0700)) {
- LOGERR("BeagleQueueIndexer:: can't create queuedir [" << (m_queuedir) << "] errno " << (errno) << "\n" );
+ LOGERR("WebQueueIndexer:: can't create queuedir [" << (m_queuedir) << "] errno " << (errno) << "\n" );
return false;
}
if (!m_cache || !m_cache->cc()) {
- LOGERR("BeagleQueueIndexer: cache initialization failed\n" );
+ LOGERR("WebQueueIndexer: cache initialization failed\n" );
return false;
}
CirCache *cc = m_cache->cc();
@@ -282,7 +284,7 @@
do {
string udi;
if (!cc->getCurrentUdi(udi)) {
- LOGERR("BeagleQueueIndexer:: cache file damaged\n" );
+ LOGERR("WebQueueIndexer:: cache file damaged\n" );
break;
}
if (udi.empty())
@@ -295,7 +297,7 @@
indexFromCache(udi);
updstatus(udi);
} catch (CancelExcept) {
- LOGERR("BeagleQueueIndexer: interrupted\n" );
+ LOGERR("WebQueueIndexer: interrupted\n" );
return false;
}
}
@@ -307,17 +309,17 @@
FsTreeWalker walker(FsTreeWalker::FtwNoRecurse);
walker.addSkippedName(".*");
FsTreeWalker::Status status = walker.walk(m_queuedir, *this);
- LOGDEB("BeagleQueueIndexer::processqueue: done: status " << (status) << "\n" );
+ LOGDEB("WebQueueIndexer::processqueue: done: status " << (status) << "\n" );
return true;
}
// Index a list of files (sent by the real time monitor)
-bool BeagleQueueIndexer::indexFiles(list<string>& files)
-{
- LOGDEB("BeagleQueueIndexer::indexFiles\n" );
+bool WebQueueIndexer::indexFiles(list<string>& files)
+{
+ LOGDEB("WebQueueIndexer::indexFiles\n" );
if (!m_db) {
- LOGERR("BeagleQueueIndexer::indexfiles no db??\n" );
+ LOGERR("WebQueueIndexer::indexfiles no db??\n" );
return false;
}
for (list<string>::iterator it = files.begin(); it != files.end();) {
@@ -326,7 +328,7 @@
}
string father = path_getfather(*it);
if (father.compare(m_queuedir)) {
- LOGDEB("BeagleQueueIndexer::indexfiles: skipping [" << *it << "] (nq)\n" );
+ LOGDEB("WebQueueIndexer::indexfiles: skipping [" << *it << "] (nq)\n" );
it++; continue;
}
// Pb: we are often called with the dot file, before the
@@ -342,11 +344,11 @@
}
struct stat st;
if (path_fileprops(*it, &st) != 0) {
- LOGERR("BeagleQueueIndexer::indexfiles: cant stat [" << *it << "]\n" );
+ LOGERR("WebQueueIndexer::indexfiles: cant stat [" << *it << "]\n" );
it++; continue;
}
if (!S_ISREG(st.st_mode)) {
- LOGDEB("BeagleQueueIndexer::indexfiles: skipping [" << *it << "] (nr)\n" );
+ LOGDEB("WebQueueIndexer::indexfiles: skipping [" << *it << "] (nr)\n" );
it++; continue;
}
@@ -360,7 +362,7 @@
}
FsTreeWalker::Status
-BeagleQueueIndexer::processone(const string &path,
+WebQueueIndexer::processone(const string &path,
const struct stat *stp,
FsTreeWalker::CbFlag flg)
{
@@ -374,9 +376,9 @@
string dotpath = path_cat(path_getfather(path),
string(".") + path_getsimple(path));
- LOGDEB("BeagleQueueIndexer: prc1: [" << (path) << "]\n" );
-
- BeagleDotFile dotfile(m_config, dotpath);
+ LOGDEB("WebQueueIndexer: prc1: [" << (path) << "]\n" );
+
+ WebQueueDotFile dotfile(m_config, dotpath);
Rcl::Doc dotdoc;
string udi, udipath;
if (!dotfile.toDoc(dotdoc))
@@ -388,7 +390,7 @@
udipath = path_cat(dotdoc.meta[Rcl::Doc::keybght], url_gpath(dotdoc.url));
make_udi(udipath, cstr_null, udi);
- LOGDEB("BeagleQueueIndexer: prc1: udi [" << (udi) << "]\n" );
+ LOGDEB("WebQueueIndexer: prc1: udi [" << (udi) << "]\n" );
char ascdate[30];
sprintf(ascdate, "%ld", long(stp->st_mtime));
@@ -410,7 +412,7 @@
} else {
Rcl::Doc doc;
// Store the dotdoc fields in the future doc. In case someone wants
- // to use beagle-generated fields like beagle:inurl
+ // to use fields generated by the browser plugin like inurl
doc.meta = dotdoc.meta;
FileInterner interner(path, stp, m_config,
@@ -420,11 +422,11 @@
try {
fis = interner.internfile(doc);
} catch (CancelExcept) {
- LOGERR("BeagleQueueIndexer: interrupted\n" );
+ LOGERR("WebQueueIndexer: interrupted\n" );
goto out;
}
if (fis != FileInterner::FIDone && fis != FileInterner::FIAgain) {
- LOGERR("BeagleQueueIndexer: bad status from internfile\n" );
+ LOGERR("WebQueueIndexer: bad status from internfile\n" );
// TOBEDONE: internfile can return FIAgain here if it is
// paging a big text file, we should loop. Means we're
// only indexing the first page for text/plain files
@@ -457,11 +459,11 @@
string fdata;
file_to_string(path, fdata);
if (!m_cache || !m_cache->cc()) {
- LOGERR("BeagleQueueIndexer: cache initialization failed\n" );
+ LOGERR("WebQueueIndexer: cache initialization failed\n" );
goto out;
}
if (!m_cache->cc()->put(udi, &dotfile.m_fields, fdata, 0)) {
- LOGERR("BeagleQueueIndexer::prc1: cache_put failed; " << (m_cache->cc()->getReason()) << "\n" );
+ LOGERR("WebQueueIndexer::prc1: cache_put failed; " << (m_cache->cc()->getReason()) << "\n" );
goto out;
}
}