From b699bbe78fecb49ed5fc35f6fd2d6e49bf48e2c9 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Tue, 11 May 2010 15:02:53 +0200 Subject: [PATCH] Write data version number at once into empty index. closes #8 --- src/rcldb/rcldb.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rcldb/rcldb.cpp b/src/rcldb/rcldb.cpp index bcea623a..256f1368 100644 --- a/src/rcldb/rcldb.cpp +++ b/src/rcldb/rcldb.cpp @@ -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