Fix invalid shard removal

This commit is contained in:
Miguel Portilla
2020-04-08 15:09:23 -04:00
committed by Nik Bougalis
parent 1c3c69f8b5
commit ce5f240551
3 changed files with 53 additions and 39 deletions

View File

@@ -52,6 +52,29 @@ Shard::Shard(
Throw<std::runtime_error>("Shard: Invalid index");
}
Shard::~Shard()
{
if (removeOnDestroy_)
{
backend_.reset();
lgrSQLiteDB_.reset();
txSQLiteDB_.reset();
acquireInfo_.reset();
try
{
boost::filesystem::remove_all(dir_);
}
catch (std::exception const& e)
{
JLOG(j_.error()) <<
"shard " << index_ <<
" exception " << e.what() <<
" in function " << __func__;
}
}
}
bool
Shard::open(Scheduler& scheduler, nudb::context& ctx)
{