From a4834e045a1fd69c83a53ecaa9b2db9b92ddc29a Mon Sep 17 00:00:00 2001 From: "fabian.peller-konrad@kit.edu" <fabian.peller-konrad@kit.edu> Date: Wed, 7 Jul 2021 09:40:13 +0200 Subject: [PATCH] fixed disk memory export --- .../libraries/armem/core/diskmemory/CoreSegment.cpp | 11 ++++++++++- .../libraries/armem/core/diskmemory/Entity.cpp | 3 ++- .../armem/core/diskmemory/EntitySnapshot.cpp | 2 +- .../libraries/armem/core/diskmemory/EntitySnapshot.h | 2 +- .../libraries/armem/core/diskmemory/Memory.cpp | 12 ++++++++++-- .../armem/core/diskmemory/ProviderSegment.cpp | 2 -- .../libraries/armem/core/longtermmemory/Entity.cpp | 2 +- 7 files changed, 25 insertions(+), 9 deletions(-) diff --git a/source/RobotAPI/libraries/armem/core/diskmemory/CoreSegment.cpp b/source/RobotAPI/libraries/armem/core/diskmemory/CoreSegment.cpp index 6a26be9c7..d838c716a 100644 --- a/source/RobotAPI/libraries/armem/core/diskmemory/CoreSegment.cpp +++ b/source/RobotAPI/libraries/armem/core/diskmemory/CoreSegment.cpp @@ -86,7 +86,16 @@ namespace armarx::armem::d_ltm } else { - std::filesystem::create_directory(_fullPath() / k); + try + { + std::filesystem::create_directory(_fullPath() / k); + } + catch (...) + { + ARMARX_WARNING << GetHandledExceptionString(); + return; + } + auto wms = _container.emplace(std::make_pair(k, id().withProviderSegmentName(k))); wms.first->second.path = path; wms.first->second.append(s); diff --git a/source/RobotAPI/libraries/armem/core/diskmemory/Entity.cpp b/source/RobotAPI/libraries/armem/core/diskmemory/Entity.cpp index a616914ed..16f66c488 100644 --- a/source/RobotAPI/libraries/armem/core/diskmemory/Entity.cpp +++ b/source/RobotAPI/libraries/armem/core/diskmemory/Entity.cpp @@ -67,7 +67,8 @@ namespace armarx::armem::d_ltm { if (const auto& it = _container.find(k); it != _container.end()) { - it->second.setTo(s); + // timestamp already exists + // We assume that a snapshot does not change, so ignore } else { diff --git a/source/RobotAPI/libraries/armem/core/diskmemory/EntitySnapshot.cpp b/source/RobotAPI/libraries/armem/core/diskmemory/EntitySnapshot.cpp index cc1124ab2..88e5c51dc 100644 --- a/source/RobotAPI/libraries/armem/core/diskmemory/EntitySnapshot.cpp +++ b/source/RobotAPI/libraries/armem/core/diskmemory/EntitySnapshot.cpp @@ -79,7 +79,7 @@ namespace armarx::armem::d_ltm return; } - // We remove the contente here and reset it with new values + // We remove the content here and reset it with new values _container.clear(); int i = 0; diff --git a/source/RobotAPI/libraries/armem/core/diskmemory/EntitySnapshot.h b/source/RobotAPI/libraries/armem/core/diskmemory/EntitySnapshot.h index f73702857..545a8c0d6 100644 --- a/source/RobotAPI/libraries/armem/core/diskmemory/EntitySnapshot.h +++ b/source/RobotAPI/libraries/armem/core/diskmemory/EntitySnapshot.h @@ -29,7 +29,7 @@ namespace armarx::armem::d_ltm void reload(const std::shared_ptr<std::filesystem::path>&); wm::EntitySnapshot convert(const aron::typenavigator::NavigatorPtr& expectedStructure) const; - // MongoDB connection + // FS connection void setTo(const wm::EntitySnapshot&); private: diff --git a/source/RobotAPI/libraries/armem/core/diskmemory/Memory.cpp b/source/RobotAPI/libraries/armem/core/diskmemory/Memory.cpp index 874d189d6..be2415c2e 100644 --- a/source/RobotAPI/libraries/armem/core/diskmemory/Memory.cpp +++ b/source/RobotAPI/libraries/armem/core/diskmemory/Memory.cpp @@ -44,7 +44,7 @@ namespace armarx::armem::d_ltm if (!std::filesystem::exists(p)) { - ARMARX_INFO << "The entered path does not exist. Assuming an empty container."; + ARMARX_INFO << "The entered path does not exist. Returning empty memory."; } else { @@ -73,7 +73,15 @@ namespace armarx::armem::d_ltm } else { - std::filesystem::create_directory(_fullPath() / k); + try + { + std::filesystem::create_directory(_fullPath() / k); + } + catch (...) + { + ARMARX_WARNING << GetHandledExceptionString(); + return; + } auto wms = _container.emplace(std::make_pair(k, id().withCoreSegmentName(k))); wms.first->second.path = path; diff --git a/source/RobotAPI/libraries/armem/core/diskmemory/ProviderSegment.cpp b/source/RobotAPI/libraries/armem/core/diskmemory/ProviderSegment.cpp index 77d38171c..bca090b81 100644 --- a/source/RobotAPI/libraries/armem/core/diskmemory/ProviderSegment.cpp +++ b/source/RobotAPI/libraries/armem/core/diskmemory/ProviderSegment.cpp @@ -107,8 +107,6 @@ namespace armarx::armem::d_ltm try { std::filesystem::create_directory(_fullPath() / k); - continue; - } catch (...) { diff --git a/source/RobotAPI/libraries/armem/core/longtermmemory/Entity.cpp b/source/RobotAPI/libraries/armem/core/longtermmemory/Entity.cpp index 3865e6df0..153852eaf 100644 --- a/source/RobotAPI/libraries/armem/core/longtermmemory/Entity.cpp +++ b/source/RobotAPI/libraries/armem/core/longtermmemory/Entity.cpp @@ -63,7 +63,7 @@ namespace armarx::armem::ltm { if (const auto& it = _container.find(k); it != _container.end()) { - // segment already exists + // timestamp already exists // We assume that a snapshot does not change, so ignore } else -- GitLab