From e2f72297e4d71c35cca71952b1739d69700ee570 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Fri, 23 Jul 2021 10:34:34 +0200 Subject: [PATCH] Fix in old session delete --- firmware/lib/session/SimpleMeasurementSession.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/firmware/lib/session/SimpleMeasurementSession.h b/firmware/lib/session/SimpleMeasurementSession.h index 1c9d479..c40261a 100644 --- a/firmware/lib/session/SimpleMeasurementSession.h +++ b/firmware/lib/session/SimpleMeasurementSession.h @@ -112,7 +112,7 @@ private: auto freeBytes = portablefs::totalBytes() - portablefs::usedBytes(); while (freeBytes < requiredSpace) { - uint32_t nextSessionToDelete = 0; + uint32_t nextSessionToDelete = uint32_t(-1); auto dir = portablefs::openDir(CONFIG_DATA_PATH); String filenameToDelete; @@ -122,7 +122,7 @@ private: { const auto fileName = dir.fileName(); const auto fileNameWithoutDir = fileName.substring(fileName.lastIndexOf("/") + 1); - auto sessionId = fileNameWithoutDir.toInt(); + uint32_t sessionId = fileNameWithoutDir.toInt(); if (sessionId < nextSessionToDelete) { nextSessionToDelete = sessionId; @@ -131,6 +131,7 @@ private: } } assert(nextSessionToDelete > 0); + assert(nextSessionToDelete < uint32_t(-1)); Serial.printf("Removing old session %s to make space\n", filenameToDelete.c_str()); portablefs::remove(filenameToDelete.c_str()); auto newFreeBytes = portablefs::totalBytes() - portablefs::usedBytes();