lib: fix batch-size after db creation
Ensure we use the user-specified batch-size immediately after db creation.
This commit is contained in:
@ -75,8 +75,11 @@ struct Store::Private {
|
||||
config_{make_config(xapian_db_, root_maildir, conf)},
|
||||
contacts_cache_{config_},
|
||||
root_maildir_{remove_slash(config_.get<Config::Id::RootMaildir>())},
|
||||
message_opts_{make_message_options(config_)}
|
||||
{}
|
||||
message_opts_{make_message_options(config_)} {
|
||||
// so tell xapian-db to update its internal cacheed values from
|
||||
// config. In practice: batch-size.
|
||||
xapian_db_.reinit();
|
||||
}
|
||||
|
||||
~Private() try {
|
||||
mu_debug("closing store @ {}", xapian_db_.path());
|
||||
|
||||
@ -101,7 +101,7 @@ make_db(const std::string& db_path, Flavor flavor)
|
||||
XapianDb::XapianDb(const std::string& db_path, Flavor flavor):
|
||||
path_(make_path(db_path, flavor)),
|
||||
db_(make_db(path_, flavor)),
|
||||
batch_size_{Config(*this).get<Config::Id::BatchSize>()}
|
||||
batch_size_{Config(*this).get<Config::Id::BatchSize>()} // default
|
||||
{
|
||||
if (flavor == Flavor::CreateOverwrite)
|
||||
set_timestamp(MetadataIface::created_key);
|
||||
@ -109,6 +109,12 @@ XapianDb::XapianDb(const std::string& db_path, Flavor flavor):
|
||||
mu_debug("created {} / {} (batch-size: {})", flavor, *this, batch_size_);
|
||||
}
|
||||
|
||||
void
|
||||
XapianDb::reinit() {
|
||||
batch_size_ = Config(*this).get<Config::Id::BatchSize>();
|
||||
mu_debug("set batch-size to {}", batch_size_);
|
||||
}
|
||||
|
||||
|
||||
#ifdef BUILD_TESTS
|
||||
/*
|
||||
|
||||
@ -222,6 +222,14 @@ public:
|
||||
mu_debug("closing db");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinitialize from inner-config. Needed after CreateOverwrite.
|
||||
*
|
||||
* This is bit of a hack, needed since we cannot setup the config
|
||||
* before we have a database.
|
||||
*/
|
||||
void reinit();
|
||||
|
||||
/**
|
||||
* Is the database read-only?
|
||||
*
|
||||
@ -545,7 +553,7 @@ private:
|
||||
std::string path_;
|
||||
DbType db_;
|
||||
size_t tx_level_{};
|
||||
const size_t batch_size_;
|
||||
size_t batch_size_;
|
||||
size_t changes_{};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user