From 5083b1f438b5d64cc773ebee47c857e3edffa0b8 Mon Sep 17 00:00:00 2001 From: Joana Plewnia <joana.plewnia@.kit.edu> Date: Tue, 4 Feb 2025 13:00:34 +0100 Subject: [PATCH] minor changes to path which is checked; also checking for size before creating repositories --- .../ltm/detail/mixins/DiskStorageMixin.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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 52e563378..7cc649d53 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"; } } -- GitLab