store/fields: Use one MaxTermLength everywhere

One should be enough!
This commit is contained in:
Dirk-Jan C. Binnema 2022-05-09 20:10:37 +03:00
parent dc69505580
commit 7470a5f8ea
4 changed files with 5 additions and 6 deletions

View File

@ -22,9 +22,6 @@
using namespace Mu; using namespace Mu;
// Xapian does not like terms much longer than this
constexpr auto MaxTermLength = 240;
std::string std::string
Field::xapian_term(const std::string& s) const Field::xapian_term(const std::string& s) const
{ {

View File

@ -30,6 +30,10 @@
namespace Mu { namespace Mu {
// Xapian does not like terms much longer than this
constexpr auto MaxTermLength = 240;
// http://article.gmane.org/gmane.comp.search.xapian.general/3656 */
struct Field { struct Field {
/** /**
* Field Ids. * Field Ids.

View File

@ -572,7 +572,7 @@ Server::Private::contacts_handler(const Parameters& params)
static std::vector<Store::Id> static std::vector<Store::Id>
docids_for_msgid(const Store& store, const std::string& msgid, size_t max = 100) docids_for_msgid(const Store& store, const std::string& msgid, size_t max = 100)
{ {
if (msgid.size() > Store::MaxTermLength) { if (msgid.size() > MaxTermLength) {
throw Error(Error::Code::InvalidArgument, throw Error(Error::Code::InvalidArgument,
"invalid message-id '%s'", msgid.c_str()); "invalid message-id '%s'", msgid.c_str());
} }

View File

@ -43,8 +43,6 @@ public:
using Id = Xapian::docid; /**< Id for a message in the store */ using Id = Xapian::docid; /**< Id for a message in the store */
static constexpr Id InvalidId = 0; /**< Invalid store id */ static constexpr Id InvalidId = 0; /**< Invalid store id */
static constexpr size_t MaxTermLength = 240; /**< Maximum length of a term,
http://article.gmane.org/gmane.comp.search.xapian.general/3656 */
/** /**
* Construct a store for an existing document database * Construct a store for an existing document database
* *