Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SD-card] Bugfix: Opening a file from SD-card doesn't always work #4776

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/src/Helpers/ESPEasy_Storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ fs::File tryOpenFile(const String& fname, const String& mode, FileDestination_e
# if FEATURE_SD

if (!f && ((destination == FileDestination_e::ANY) || (destination == FileDestination_e::SD))) {
// FIXME TD-er: Should this fallback to SD only be done on "r" mode?
f = SD.open(fname.c_str(), mode.c_str());
f = SD.open(patch_fname(fname).c_str(), mode.c_str());
}
# endif // if FEATURE_SD

Expand Down
5 changes: 1 addition & 4 deletions src/src/WebServer/FileList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,9 @@ void handle_SDfilelist() {
// size_t entrynameLength = strlen(entry.name());
if (entry.isDirectory())
{
char SDcardChildDir[80];

// take a look in the directory for entries
String child_dir = current_dir + entry.name();
child_dir.toCharArray(SDcardChildDir, child_dir.length() + 1);
fs::File child = SD.open(SDcardChildDir);
fs::File child = SD.open(child_dir.c_str());
fs::File dir_has_entry = child.openNextFile();

// when the directory is empty, display the button to delete them
Expand Down