Skip to content
Snippets Groups Projects
Commit 11f6d18d authored by Fabian Reister's avatar Fabian Reister
Browse files

Merge branch 'armem/ltm-disk-fs-guard' into 'armem/dev'

LTM filesystem export: catching exceptions related to fs::create_directories

See merge request ArmarX/RobotAPI!159
parents 18188a42 c5028e7a
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
#include <fstream>
#include "../../core/error.h"
#include "ArmarXCore/core/exceptions/LocalException.h"
#include <ArmarXCore/core/exceptions/local/ExpressionException.h>
......@@ -99,7 +100,16 @@ namespace armarx::armem::d_ltm
void EntityInstance::setTo(const wm::EntityInstance& m)
{
std::filesystem::path p = _fullPath();
std::filesystem::create_directories(p);
try
{
std::filesystem::create_directories(p);
}
catch (...)
{
ARMARX_WARNING << GetHandledExceptionString();
return;
}
std::filesystem::path d = p / (std::string(DATA_FILENAME) + ".json");
......
......@@ -69,7 +69,15 @@ namespace armarx::armem::d_ltm
void EntitySnapshot::setTo(const wm::EntitySnapshot& m)
{
std::filesystem::create_directories(_fullPath());
try
{
std::filesystem::create_directories(_fullPath());
}
catch (...)
{
ARMARX_WARNING << GetHandledExceptionString();
return;
}
// We remove the contente here and reset it with new values
_container.clear();
......@@ -77,7 +85,15 @@ namespace armarx::armem::d_ltm
int i = 0;
for (const auto& s : m.instances())
{
std::filesystem::create_directory(_fullPath() / std::to_string(i));
try
{
std::filesystem::create_directory(_fullPath() / std::to_string(i));
}
catch (...)
{
ARMARX_WARNING << GetHandledExceptionString();
continue;;
}
auto wms = _container.emplace_back(id().withInstanceIndex(i++));
wms.path = path;
......
......@@ -81,7 +81,18 @@ namespace armarx::armem::d_ltm
void ProviderSegment::append(const wm::ProviderSegment& m)
{
std::filesystem::create_directories(_fullPath());
try
{
std::filesystem::create_directories(_fullPath());
}
catch (...)
{
ARMARX_WARNING << GetHandledExceptionString();
return;
}
TypeIO::writeAronType(_aronType, _fullPath());
for (const auto& [k, s] : m.container())
......@@ -92,7 +103,19 @@ namespace armarx::armem::d_ltm
}
else
{
std::filesystem::create_directory(_fullPath() / k);
try
{
std::filesystem::create_directory(_fullPath() / k);
continue;
}
catch (...)
{
ARMARX_WARNING << GetHandledExceptionString();
return;
}
auto wms = _container.emplace(std::make_pair(k, id().withEntityName(k)));
wms.first->second.path = path;
wms.first->second.append(s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment