Remove zero length files at startup
This commit is contained in:
parent
403ed1d350
commit
7678bb1f43
@ -1194,6 +1194,22 @@ bool WebServerHandler::setupWebServer() {
|
|||||||
MDNS.begin(myConfig.getMDNS());
|
MDNS.begin(myConfig.getMDNS());
|
||||||
MDNS.addService("http", "tcp", 80);
|
MDNS.addService("http", "tcp", 80);
|
||||||
|
|
||||||
|
// Show files in the filessytem at startup
|
||||||
|
FSInfo fs;
|
||||||
|
LittleFS.info(fs);
|
||||||
|
Log.notice(F("WEB : File system Total=%d, Used=%d." CR), fs.totalBytes,
|
||||||
|
fs.usedBytes);
|
||||||
|
Dir dir = LittleFS.openDir("/");
|
||||||
|
while (dir.next()) {
|
||||||
|
Log.notice(F("WEB : File=%s, %d bytes" CR), dir.fileName().c_str(),
|
||||||
|
dir.fileSize());
|
||||||
|
if (!dir.fileSize()) {
|
||||||
|
Log.notice(F("WEB : Empty file detected, removing file." CR));
|
||||||
|
LittleFS.remove(dir.fileName().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Static content
|
// Static content
|
||||||
#if defined(EMBED_HTML)
|
#if defined(EMBED_HTML)
|
||||||
_server->on("/", std::bind(&WebServerHandler::webReturnIndexHtm, this));
|
_server->on("/", std::bind(&WebServerHandler::webReturnIndexHtm, this));
|
||||||
@ -1210,18 +1226,6 @@ bool WebServerHandler::setupWebServer() {
|
|||||||
_server->on("/test.htm",
|
_server->on("/test.htm",
|
||||||
std::bind(&WebServerHandler::webReturnTestHtm, this));
|
std::bind(&WebServerHandler::webReturnTestHtm, this));
|
||||||
#else
|
#else
|
||||||
// Show files in the filessytem at startup
|
|
||||||
|
|
||||||
FSInfo fs;
|
|
||||||
LittleFS.info(fs);
|
|
||||||
Log.notice(F("WEB : File system Total=%d, Used=%d." CR), fs.totalBytes,
|
|
||||||
fs.usedBytes);
|
|
||||||
Dir dir = LittleFS.openDir("/");
|
|
||||||
while (dir.next()) {
|
|
||||||
Log.notice(F("WEB : File=%s, %d bytes" CR), dir.fileName().c_str(),
|
|
||||||
dir.fileSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the html files exist, if so serve them, else show the static
|
// Check if the html files exist, if so serve them, else show the static
|
||||||
// upload page.
|
// upload page.
|
||||||
if (checkHtmlFile(HTML_INDEX) && checkHtmlFile(HTML_CONFIG) &&
|
if (checkHtmlFile(HTML_INDEX) && checkHtmlFile(HTML_CONFIG) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user