From a8ab40674fcae17e8e33e3aef43f6838ad9de287 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 24 Jun 2023 11:08:50 +0200 Subject: [PATCH] seems to work well --- mission/tmtc/PersistentTmStore.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mission/tmtc/PersistentTmStore.cpp b/mission/tmtc/PersistentTmStore.cpp index 6a92cdf1..f8830170 100644 --- a/mission/tmtc/PersistentTmStore.cpp +++ b/mission/tmtc/PersistentTmStore.cpp @@ -17,6 +17,8 @@ using namespace returnvalue; +static constexpr bool DEBUG_DUMPS = false; + PersistentTmStore::PersistentTmStore(PersistentTmStoreArgs args) : SystemObject(args.objectId), tmStore(args.tmStore), @@ -75,7 +77,12 @@ ReturnValue_t PersistentTmStore::buildDumpSet(uint32_t fromUnixSeconds, uint32_t DumpIndex dumpIndex; dumpIndex.epoch = fileEpoch; dumpIndex.suffixIdx = extractSuffix(file.string()); - // sif::debug << "Inserting file " << fileOrDir.path() << std::endl; + if (DEBUG_DUMPS) { + sif::debug << "Inserting file " << fileOrDir.path() << std::endl; + if (dumpIndex.suffixIdx.has_value()) { + sif::debug << "Suffix: " << static_cast(dumpIndex.suffixIdx.value()) << std::endl; + } + } dumpParams.orderedDumpFilestamps.emplace(dumpIndex); } } @@ -94,8 +101,8 @@ std::optional PersistentTmStore::extractSuffix(const std::string& pathS std::optional number; try { number = std::stoi(numberStr); - if (number < 0 or number > std::numeric_limits::max()) { - return number; + if (number.value() > std::numeric_limits::max()) { + return std::nullopt; } } catch (std::invalid_argument& exception) { @@ -309,7 +316,9 @@ ReturnValue_t PersistentTmStore::loadNextDumpFile() { sif::error << "PersistentTmStore: File is bad. Loading next file" << std::endl; continue; } - // sif::debug << baseName << " dump: Loading " << dumpParams.currentFile << std::endl; + if (DEBUG_DUMPS) { + sif::debug << baseName << " dump: Loading " << dumpParams.currentFile << std::endl; + } ifile.read(reinterpret_cast(fileBuf.data()), static_cast(dumpParams.fileSize)); // Increment iterator for next cycle.