diff --git a/source/RobotAPI/libraries/armem/server/ltm/detail/mixins/DiskStorageMixin.cpp b/source/RobotAPI/libraries/armem/server/ltm/detail/mixins/DiskStorageMixin.cpp index 52e563378fa14a12f9dfacd6bb87418227a770a2..7cc649d53aa9e9eef9eb7428c6d2bb27060fce3b 100644 --- a/source/RobotAPI/libraries/armem/server/ltm/detail/mixins/DiskStorageMixin.cpp +++ b/source/RobotAPI/libraries/armem/server/ltm/detail/mixins/DiskStorageMixin.cpp @@ -133,7 +133,9 @@ namespace armarx::armem::server::ltm::detail::mixin DiskMemoryItemMixin::ensureFullPathExists(bool createIfNotExistent) const { auto p = getFullPath(); - util::fs::ensureDirectoryExists(p, createIfNotExistent); + if(enoughDiskSpaceLeft()){ + util::fs::ensureDirectoryExists(p, createIfNotExistent); + } } void @@ -141,13 +143,16 @@ namespace armarx::armem::server::ltm::detail::mixin bool createIfNotExistent) const { auto p = getFullPath() / filename; - util::fs::ensureFileExists(p, createIfNotExistent); + if(enoughDiskSpaceLeft()){ + util::fs::ensureDirectoryExists(p, createIfNotExistent); + } } bool DiskMemoryItemMixin::enoughDiskSpaceLeft() const { - std::string path_to_disk = "/dev/mapper/ubuntu--vg-root\\"; + std::string path_to_disk = this->getMemoryBasePath();; + ARMARX_DEBUG << "Checking availability of disk space at " << path_to_disk; if (std::filesystem::exists(path_to_disk)) { @@ -178,6 +183,10 @@ namespace armarx::armem::server::ltm::detail::mixin ARMARX_WARNING << "Error: " << e.what() << '\n'; return false; } + catch (...){ + ARMARX_DEBUG << "Error while trying to get info on available disk space"; + return false; + } } else { @@ -198,7 +207,7 @@ namespace armarx::armem::server::ltm::detail::mixin } else { - ARMARX_DEBUG << "Canot store snapshot as not enough disk space available"; + ARMARX_DEBUG << "Canot store snapshot as not enough disk space is available"; } }