Write data version number at once into empty index. closes #8

This commit is contained in:
Jean-Francois Dockes 2010-05-11 15:02:53 +02:00
parent 61f3087efa
commit b699bbe78f

View File

@ -556,6 +556,11 @@ bool Db::open(OpenMode mode)
int action = (mode == DbUpd) ? Xapian::DB_CREATE_OR_OPEN :
Xapian::DB_CREATE_OR_OVERWRITE;
m_ndb->xwdb = Xapian::WritableDatabase(dir, action);
// If db is empty, write the data format version at once
// to avoid stupid error messages:
if (m_ndb->xwdb.get_doccount() == 0)
m_ndb->xwdb.set_metadata(RCL_IDX_VERSION_KEY,
RCL_IDX_VERSION);
m_ndb->m_iswritable = true;
// We open a readonly object in all cases (possibly in
// addition to the r/w one) because some operations