Add possibility to update the index for a list of files from the GUI and use it to allow updating the index before accessing a file using stale data

This commit is contained in:
Jean-Francois Dockes
2012-02-03 15:51:03 +01:00
parent 6760051652
commit 6b24c3df6b
5 changed files with 74 additions and 9 deletions
+32
View File
@@ -149,6 +149,38 @@ bool ConfIndexer::indexFiles(std::list<string>& ifiles, IxFlag flag)
return ret;
}
// Update index for specific documents. The docs come from an index
// query, so the udi, backend etc. fields are filled.
bool ConfIndexer::updateDocs(std::vector<Rcl::Doc> &docs, IxFlag flag)
{
list<string> files;
for (vector<Rcl::Doc>::iterator it = docs.begin(); it != docs.end(); it++) {
Rcl::Doc &idoc = *it;
string backend;
idoc.getmeta(Rcl::Doc::keybcknd, &backend);
// This only makes sense for file system files: beagle docs are
// always up to date because they can't be updated in the cache,
// only added/removed. Same remark as made inside internfile, we
// need a generic way to handle backends.
if (!backend.empty() && backend.compare("FS"))
continue;
// Filesystem document. Intern from file.
// The url has to be like file://
if (idoc.url.find(cstr_fileu) != 0) {
LOGERR(("idx::updateDocs: FS backend and non fs url: [%s]\n",
idoc.url.c_str()));
continue;
}
files.push_back(idoc.url.substr(7, string::npos));
}
if (!files.empty()) {
return indexFiles(files, flag);
}
return true;
}
bool ConfIndexer::purgeFiles(std::list<string> &files)
{
list<string> myfiles;
+5
View File
@@ -29,6 +29,7 @@ using std::map;
#include "rclconfig.h"
#include "rcldb.h"
#include "rcldoc.h"
class FsIndexer;
class BeagleQueueIndexer;
@@ -96,6 +97,10 @@ class ConfIndexer {
/** Index a list of files. No db cleaning or stemdb updating */
bool indexFiles(std::list<string> &files, IxFlag f = IxFNone);
/** Update index for list of documents given as list of docs (out of query)
*/
bool updateDocs(std::vector<Rcl::Doc> &docs, IxFlag f = IxFNone);
/** Purge a list of files. */
bool purgeFiles(std::list<string> &files);