From ffcc49b9e5a9415c70dafaf53752588e8c7caf21 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 8 Jan 2020 11:23:47 -0800 Subject: [PATCH] ircd::db: Add interface to checksum per file. --- include/ircd/db/database.h | 1 + ircd/db.cc | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/ircd/db/database.h b/include/ircd/db/database.h index fa43ec983..a5e603414 100644 --- a/include/ircd/db/database.h +++ b/include/ircd/db/database.h @@ -52,6 +52,7 @@ namespace ircd::db void bgcontinue(database &); void bgpause(database &); void resume(database &); + void check(database &, const string_view &file); void check(database &); void compact(database &, const std::pair &level, const compactor & = {}); void compact(database &, const compactor & = {}); diff --git a/ircd/db.cc b/ircd/db.cc index dfb0ed552..c6d8f1bb4 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -472,6 +472,46 @@ ircd::db::check(database &d) }; } +void +ircd::db::check(database &d, + const string_view &file) +{ + assert(file); + assert(d.d); + + const auto &opts + { + d.d->GetOptions() + }; + + const rocksdb::EnvOptions env_opts + { + opts + }; + + const bool absolute + { + fs::is_absolute(file) + }; + + const string_view parts[] + { + d.path, file + }; + + const std::string path + { + !absolute? + fs::path_string(parts): + std::string{file} + }; + + throw_on_error + { + rocksdb::VerifySstFileChecksum(opts, env_opts, path) + }; +} + void ircd::db::resume(database &d) {