From 2933e406fb35d678fd427e601b20227770650353 Mon Sep 17 00:00:00 2001 From: Luc Date: Fri, 16 Aug 2019 21:59:49 +0200 Subject: [PATCH] add check if filesystem error --- esp3d/src/modules/http/handles/handle-files.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/esp3d/src/modules/http/handles/handle-files.cpp b/esp3d/src/modules/http/handles/handle-files.cpp index 63d84a92..cee86a95 100644 --- a/esp3d/src/modules/http/handles/handle-files.cpp +++ b/esp3d/src/modules/http/handles/handle-files.cpp @@ -190,8 +190,14 @@ void HTTP_Server::handleFSFileList () } } buffer2send += "],\"path\":\"" + path + "\","; + + if (ESP_FileSystem::totalBytes()>0) { + buffer2send += "\"occupation\":\"" + String(100*ESP_FileSystem::usedBytes()/ESP_FileSystem::totalBytes()) + "\","; + } else { + status = "FileSystem Error"; + buffer2send += "\"occupation\":\"0\","; + } buffer2send += "\"status\":\"" + status + "\","; - buffer2send += "\"occupation\":\"" + String(100*ESP_FileSystem::usedBytes()/ESP_FileSystem::totalBytes()) + "\","; buffer2send += "\"total\":\"" + ESP_FileSystem::formatBytes (ESP_FileSystem::totalBytes()) + "\","; buffer2send += "\"used\":\"" + ESP_FileSystem::formatBytes (ESP_FileSystem::usedBytes()) + "\"}"; path = "";