fix problems with doc fetch sequence (have to know where to stop)
This commit is contained in:
parent
cf07573b57
commit
b20222b150
@ -254,7 +254,7 @@ void ResListBase::showResultPage()
|
||||
// Insert results if any in result list window. We have to send
|
||||
// the text to the widgets, because we need the paragraph number
|
||||
// each time we add a result paragraph (its diffult and
|
||||
// error-prone to compute the paragraph numbers in parallel. We
|
||||
// error-prone to compute the paragraph numbers in parallel). We
|
||||
// would like to disable updates while we're doing this, but
|
||||
// couldn't find a way to make it work, the widget seems to become
|
||||
// confused if appended while updates are disabled
|
||||
@ -264,8 +264,12 @@ void ResListBase::showResultPage()
|
||||
doc.erase();
|
||||
|
||||
if (!m_docsource->getDoc(m_winfirst + i, doc, &percent, &sh)) {
|
||||
// This may very well happen for history if the doc has
|
||||
// been removed since. So don't treat it as fatal.
|
||||
// Error or end of docs, stop.
|
||||
break;
|
||||
}
|
||||
if (percent == -1) {
|
||||
percent = 0;
|
||||
// Document not available, maybe other further, will go on.
|
||||
doc.abstract = string(tr("Unavailable document").utf8());
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: docseq.cpp,v 1.7 2006-01-26 12:30:14 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: docseq.cpp,v 1.8 2006-02-07 10:26:49 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -38,9 +38,9 @@ int DocSequenceDb::getResCnt()
|
||||
return m_rescnt;
|
||||
}
|
||||
|
||||
|
||||
bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, int *percent,
|
||||
string *sh) {
|
||||
string *sh)
|
||||
{
|
||||
// Retrieve history list
|
||||
if (!m_hist)
|
||||
return false;
|
||||
@ -72,7 +72,7 @@ bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, int *percent,
|
||||
} else
|
||||
sh->erase();
|
||||
}
|
||||
return m_db->getDoc(m_it->fn, m_it->ipath, doc);
|
||||
return m_db->getDoc(m_it->fn, m_it->ipath, doc, percent);
|
||||
}
|
||||
|
||||
int DocSequenceHistory::getResCnt()
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _DOCSEQ_H_INCLUDED_
|
||||
#define _DOCSEQ_H_INCLUDED_
|
||||
/* @(#$Id: docseq.h,v 1.5 2006-01-30 11:15:28 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: docseq.h,v 1.6 2006-02-07 10:26:49 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include "rcldb.h"
|
||||
#include "history.h"
|
||||
@ -31,6 +31,19 @@ class DocSequence {
|
||||
public:
|
||||
DocSequence(const std::string &t) : m_title(t) {}
|
||||
virtual ~DocSequence() {}
|
||||
/** Get document at given rank
|
||||
*
|
||||
* @param num document rank in sequence
|
||||
* @param doc return data
|
||||
* @param percent this will be updated with the percentage of relevance, if
|
||||
* available, depending on the type of sequence. Return -1 in there
|
||||
* to indicate that the specified document data is
|
||||
* unavailable but that there may be available data further
|
||||
* in the sequence
|
||||
* @param sh subheader to display before this result (ie: date change
|
||||
* inside history)
|
||||
* @return true if ok, false for error or end of data
|
||||
*/
|
||||
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0)
|
||||
= 0;
|
||||
virtual int getResCnt() = 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.56 2006-02-02 08:58:11 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.57 2006-02-07 10:26:49 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -1305,7 +1305,7 @@ bool Rcl::Db::getDoc(int exti, Doc &doc, int *percent)
|
||||
// Retrieve document defined by file name and internal path. Very inefficient,
|
||||
// used only for history display. We'd need to enter path+ipath terms in the
|
||||
// db if we wanted to make this more efficient.
|
||||
bool Rcl::Db::getDoc(const string &fn, const string &ipath, Doc &doc)
|
||||
bool Rcl::Db::getDoc(const string &fn, const string &ipath, Doc &doc, int *pc)
|
||||
{
|
||||
LOGDEB(("Rcl::Db:getDoc: [%s] (%d) [%s]\n", fn.c_str(), fn.length(),
|
||||
ipath.c_str()));
|
||||
@ -1313,18 +1313,29 @@ bool Rcl::Db::getDoc(const string &fn, const string &ipath, Doc &doc)
|
||||
return false;
|
||||
Native *ndb = (Native *)pdata;
|
||||
|
||||
// Initialize what we can in any case. If this is history, caller
|
||||
// will make partial display in case of error
|
||||
doc.ipath = ipath;
|
||||
doc.url = string("file://") + fn;
|
||||
if (*pc)
|
||||
*pc = 100;
|
||||
|
||||
string hash;
|
||||
pathHash(fn, hash, PATHHASHLEN);
|
||||
string pathterm = "P" + hash;
|
||||
|
||||
// Look for all documents with this path, searching for the one
|
||||
// with the appropriate ipath. This is very inefficient.
|
||||
const char *ermsg = "";
|
||||
try {
|
||||
if (!ndb->db.term_exists(pathterm)) {
|
||||
char len[20];
|
||||
sprintf(len, "%d", int(pathterm.length()));
|
||||
throw string("path inexistant: [") + pathterm +"] length " + len;
|
||||
// Document found in history no longer in the database.
|
||||
// We return true (because their might be other ok docs further)
|
||||
// but indicate the error with pc = -1
|
||||
if (*pc)
|
||||
*pc = -1;
|
||||
LOGINFO(("Rcl::Db:getDoc: path inexistant: [%s] length %d\n",
|
||||
pathterm.c_str(), pathterm.length()));
|
||||
return true;
|
||||
}
|
||||
for (Xapian::PostingIterator docid =
|
||||
ndb->db.postlist_begin(pathterm);
|
||||
@ -1348,10 +1359,6 @@ bool Rcl::Db::getDoc(const string &fn, const string &ipath, Doc &doc)
|
||||
}
|
||||
if (*ermsg) {
|
||||
LOGERR(("Rcl::Db::getDoc: %s\n", ermsg));
|
||||
// Initialize what we can anyway. If this is history, caller
|
||||
// will make partial display
|
||||
doc.ipath = ipath;
|
||||
doc.url = string("file://") + fn;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _DB_H_INCLUDED_
|
||||
#define _DB_H_INCLUDED_
|
||||
/* @(#$Id: rcldb.h,v 1.24 2006-01-30 11:15:27 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: rcldb.h,v 1.25 2006-02-07 10:26:49 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
@ -154,7 +154,7 @@ class Db {
|
||||
bool getDoc(int i, Doc &doc, int *percent = 0);
|
||||
|
||||
/** Get document for given filename and ipath */
|
||||
bool getDoc(const string &fn, const string &ipath, Doc &doc);
|
||||
bool getDoc(const string &fn, const string &ipath, Doc &doc, int *percent);
|
||||
|
||||
/** Get results count for current query */
|
||||
int getResCnt();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user