build: bump schema version, update contacts-cache

Bump schema version to trigger update after we added html processing.

Since we're updating the database schema version, let's use the
opportunity to remove outdated data from the contacts-cache.
This commit is contained in:
Dirk-Jan C. Binnema
2023-01-31 23:22:53 +02:00
parent abfa6f277c
commit 2255769de7
2 changed files with 10 additions and 15 deletions

View File

@ -124,17 +124,17 @@ ContactsCache::Private::deserialize(const std::string& serialized) const
while (getline(ss, line)) { while (getline(ss, line)) {
const auto parts = Mu::split(line, Separator); const auto parts = Mu::split(line, Separator);
if (G_UNLIKELY(parts.size() != 6)) { if (G_UNLIKELY(parts.size() != 5)) {
g_warning("error: '%s'", line.c_str()); g_warning("error: '%s'", line.c_str());
continue; continue;
} }
Contact ci(parts[1], // email Contact ci(parts[0], // email
std::move(parts[2]), // name std::move(parts[1]), // name
(time_t)g_ascii_strtoll(parts[4].c_str(), NULL, 10), // message_date (time_t)g_ascii_strtoll(parts[3].c_str(), NULL, 10), // message_date
parts[3][0] == '1' ? true : false, // personal parts[2][0] == '1' ? true : false, // personal
(std::size_t)g_ascii_strtoll(parts[5].c_str(), NULL, 10), // frequency (std::size_t)g_ascii_strtoll(parts[4].c_str(), NULL, 10), // frequency
g_get_monotonic_time()); // tstamp g_get_monotonic_time()); // tstamp
contacts.emplace(std::move(parts[1]), std::move(ci)); contacts.emplace(std::move(parts[0]), std::move(ci));
} }
return contacts; return contacts;
@ -146,25 +146,20 @@ ContactsCache::ContactsCache(const std::string& serialized, const StringVec& per
} }
ContactsCache::~ContactsCache() = default; ContactsCache::~ContactsCache() = default;
std::string std::string
ContactsCache::serialize() const ContactsCache::serialize() const
{ {
std::lock_guard<std::mutex> l_{priv_->mtx_}; std::lock_guard<std::mutex> l_{priv_->mtx_};
std::string s; std::string s;
// XXX: 'display_name' is cached but unused; remove it, the next time we
// update the database schema.
for (auto& item : priv_->contacts_) { for (auto& item : priv_->contacts_) {
const auto& ci{item.second}; const auto& ci{item.second};
s += Mu::format("%s%s" s += Mu::format("%s%s"
"%s%s"
"%s%s" "%s%s"
"%d%s" "%d%s"
"%" G_GINT64_FORMAT "%s" "%" G_GINT64_FORMAT "%s"
"%" G_GINT64_FORMAT "\n", "%" G_GINT64_FORMAT "\n",
ci.display_name().c_str(),
Separator,
ci.email.c_str(), ci.email.c_str(),
Separator, Separator,
ci.name.c_str(), ci.name.c_str(),

View File

@ -86,7 +86,7 @@ cxx.check_header('charconv', required:true)
# config.h setup # config.h setup
# #
config_h_data=configuration_data() config_h_data=configuration_data()
config_h_data.set_quoted('MU_STORE_SCHEMA_VERSION', '465') config_h_data.set_quoted('MU_STORE_SCHEMA_VERSION', '466')
config_h_data.set_quoted('PACKAGE_VERSION', meson.project_version()) config_h_data.set_quoted('PACKAGE_VERSION', meson.project_version())
config_h_data.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + config_h_data.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' +
meson.project_version()) meson.project_version())