Fix in old session delete

This commit is contained in:
Martin Bauer 2021-07-23 10:34:34 +02:00
parent fb0b455910
commit e2f72297e4
1 changed files with 3 additions and 2 deletions

View File

@ -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();