Skip to content

Commit

Permalink
don't serve files if sd bad
Browse files Browse the repository at this point in the history
  • Loading branch information
acvigue committed Jul 25, 2023
1 parent e905f35 commit 21951f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/RdFileManager/FileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class FileManager
bool _spiffsIsOk;
bool _enableSD;
bool _defaultToSPIFFS;
bool _sdIsOk;
bool _cachedFileListValid;

FILE* pChunkedFile = NULL;
Expand Down Expand Up @@ -71,6 +70,8 @@ class FileManager
void uploadAPIBlockHandler(const char* fileSystem, const String& req, const String& filename, int fileLength, size_t index, uint8_t *data, size_t len, bool finalBlock);
void uploadAPIBlocksComplete();

bool _sdIsOk;

// Delete file on file system
bool deleteFile(const String& fileSystemStr, const String& filename);

Expand Down
6 changes: 5 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ void setup() {
webServer.setup(hwConfig);
webServer.addEndpoints(restAPIEndpoints);
webServer.serveStaticFiles("/", "/spiffs/", "public, max-age=31536000");
webServer.serveStaticFiles("/files/sd", "/sd/");
if(fileManager._sdIsOk) {
webServer.serveStaticFiles("/files/sd", "/sd/");
} else {
ESP_LOGE("main", "WEB APP WILL NOT FUNCTION PROPERLY WITHOUT AN ATTACHED SD CARD.");
}
webServer.enableAsyncEvents("/events");
webServer.webSocketOpen("/socket");

Expand Down

0 comments on commit 21951f7

Please sign in to comment.