From 73b6ebf300a1c1f6a777f50f46e178a8e7697342 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 9 Jun 2010 16:29:02 +0200 Subject: [PATCH] simplify calls to update index status --- src/index/indexer.cpp | 22 +++++++--------------- src/index/indexer.h | 13 ++++++++++--- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/index/indexer.cpp b/src/index/indexer.cpp index a9f708d4..ab32f3dc 100644 --- a/src/index/indexer.cpp +++ b/src/index/indexer.cpp @@ -80,19 +80,14 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun) if (typestorun == IxTAll) { // Get rid of all database entries that don't exist in the // filesystem anymore. Only if all *configured* indexers ran. - if (m_updater) { - m_updater->status.fn.erase(); - m_updater->status.phase = DbIxStatus::DBIXS_PURGE; - m_updater->update(); - } + if (m_updater) + m_updater->update(DbIxStatus::DBIXS_PURGE, string()); m_db.purge(); } - if (m_updater) { - m_updater->status.phase = DbIxStatus::DBIXS_CLOSING; - m_updater->status.fn.erase(); - m_updater->update(); - } + if (m_updater) + m_updater->update(DbIxStatus::DBIXS_CLOSING, string()); + // The close would be done in our destructor, but we want status here if (!m_db.close()) { LOGERR(("ConfIndexer::index: error closing database in %s\n", @@ -211,11 +206,8 @@ bool ConfIndexer::createStemmingDatabases() m_db.deleteStemDb(*it); } for (it = langs.begin(); it != langs.end(); it++) { - if (m_updater) { - m_updater->status.phase = DbIxStatus::DBIXS_STEMDB; - m_updater->status.fn = *it; - m_updater->update(); - } + if (m_updater) + m_updater->update(DbIxStatus::DBIXS_STEMDB, *it); m_db.createStemDb(*it); } } diff --git a/src/index/indexer.h b/src/index/indexer.h index 8b6b4953..9256a5c2 100644 --- a/src/index/indexer.h +++ b/src/index/indexer.h @@ -52,12 +52,19 @@ class DbIxStatusUpdater { DbIxStatus status; virtual ~DbIxStatusUpdater(){} virtual bool update() = 0; + virtual bool update(DbIxStatus::Phase phase, const string& fn) + { + status.phase = phase; + status.fn = fn; + return update(); + } }; /** - * The top level indexing object. Processes the configuration, then invokes - * file system walking or other to populate/update the database(s). -*/ + * The top level batch indexing object. Processes the configuration, + * then invokes file system walking or other to populate/update the + * database(s). + */ class ConfIndexer { public: enum runStatus {IndexerOk, IndexerError};