summary refs log tree commit diff
path: root/src/Cache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Cache.cpp')
-rw-r--r--src/Cache.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp

index eb5c93aa..1a097cff 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp
@@ -665,8 +665,15 @@ Cache::deleteData() } } +//! migrates db to the current format bool -Cache::isFormatValid() +Cache::runMigrations() +{ + return true; +} + +cache::CacheVersion +Cache::formatVersion() { auto txn = lmdb::txn::begin(env_, nullptr, MDB_RDONLY); @@ -676,18 +683,16 @@ Cache::isFormatValid() txn.commit(); if (!res) - return false; + return cache::CacheVersion::Older; std::string stored_version(current_version.data(), current_version.size()); - if (stored_version != CURRENT_CACHE_FORMAT_VERSION) { - nhlog::db()->warn("breaking changes in the cache format. stored: {}, current: {}", - stored_version, - CURRENT_CACHE_FORMAT_VERSION); - return false; - } - - return true; + if (stored_version < CURRENT_CACHE_FORMAT_VERSION) + return cache::CacheVersion::Older; + else if (stored_version > CURRENT_CACHE_FORMAT_VERSION) + return cache::CacheVersion::Older; + else + return cache::CacheVersion::Current; } void @@ -2468,10 +2473,17 @@ setup() } bool -isFormatValid() +runMigrations() +{ + return instance_->runMigrations(); +} + +cache::CacheVersion +formatVersion() { - return instance_->isFormatValid(); + return instance_->formatVersion(); } + void setCurrentFormat() {