mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
modules/console: Split db compact into db compact files.
This commit is contained in:
parent
4f1b9b6f6f
commit
f1556f880e
1 changed files with 54 additions and 2 deletions
|
@ -1493,9 +1493,61 @@ try
|
|||
};
|
||||
|
||||
compact(column, range, level);
|
||||
}};
|
||||
|
||||
if(level >= -1 && range.first.empty() && range.second.empty())
|
||||
compact(column, level);
|
||||
if(colname != "*")
|
||||
compact_column(colname);
|
||||
else
|
||||
for(const auto &column : database.columns)
|
||||
compact_column(name(*column));
|
||||
|
||||
out << "done" << std::endl;
|
||||
return true;
|
||||
}
|
||||
catch(const std::out_of_range &e)
|
||||
{
|
||||
out << "No open database by that name" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__db__compact__files(opt &out, const string_view &line)
|
||||
try
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"dbname", "[colname]", "[level]"
|
||||
}};
|
||||
|
||||
const auto dbname
|
||||
{
|
||||
param.at(0)
|
||||
};
|
||||
|
||||
const auto colname
|
||||
{
|
||||
param.at(1, "*"_sv)
|
||||
};
|
||||
|
||||
const auto level
|
||||
{
|
||||
param.at(2, -1)
|
||||
};
|
||||
|
||||
auto &database
|
||||
{
|
||||
db::database::get(dbname)
|
||||
};
|
||||
|
||||
const auto compact_column{[&out, &database, &level]
|
||||
(const string_view &colname)
|
||||
{
|
||||
db::column column
|
||||
{
|
||||
database, colname
|
||||
};
|
||||
|
||||
compact(column, level);
|
||||
}};
|
||||
|
||||
if(colname != "*")
|
||||
|
|
Loading…
Reference in a new issue