0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd::db: Add interface to checksum files per column.

modules/console: Add column params to db check cmd.
This commit is contained in:
Jason Volk 2020-01-08 11:24:27 -08:00
parent ffcc49b9e5
commit cdfdde3334
3 changed files with 48 additions and 2 deletions

View file

@ -70,6 +70,7 @@ namespace ircd::db
void compact(column &, const std::pair<string_view, string_view> &, const int &to_level = -1, const compactor & = {});
void compact(column &, const std::pair<int, int> &level = {-1, -1}, const compactor & = {});
void sort(column &, const bool &blocking = false, const bool &now = false);
void check(column &);
void drop(column &); // danger
}

View file

@ -5960,6 +5960,27 @@ ircd::db::drop(column &column)
drop(c);
}
void
ircd::db::check(column &column)
{
database &d(column);
const auto &files
{
db::files(column)
};
for(const auto &file : files)
{
const auto &path
{
// remove false leading slash; the rest is relative to db.
lstrip(file, '/')
};
db::check(d, path);
}
}
void
ircd::db::sort(column &column,
const bool &blocking,

View file

@ -4399,9 +4399,19 @@ bool
console_cmd__db__check(opt &out, const string_view &line)
try
{
const auto dbname
const params param{line, " ",
{
token(line, ' ', 0)
"dbname", "column"
}};
const auto &dbname
{
param.at("dbname")
};
const auto &colname
{
param["column"]
};
auto &database
@ -4409,6 +4419,20 @@ try
db::database::get(dbname)
};
if(colname)
{
db::column column
{
database[colname]
};
check(column);
out << "Check of " << colname << " in " << dbname << " completed without error."
<< std::endl;
return true;
}
check(database);
out << "Check of " << dbname << " completed without error."
<< std::endl;