Help with LittleFS webserver

Hey Guys,

I've been tinkering with [this brilliant little async webserver](ESP32-OTA-File-management/OTA_file_management.ino at main · AR-D-R/ESP32-OTA-File-management (github.com))

When written, It was based on SPIFFS and the guidance ive had is to migrate it to LittleFS by changing all the SPIFFSreferences to LittleFS.
The server works perfectly except for when i delete a file, i get this error in the serial monitor and the file remains in the list of files.

image

The code which handles the delete function is

 void deleteFile(fs::FS &fs, const String& path) {
  Serial.printf("Deleting file: %s\r\n", path);
  if (fs.remove(path)) {
    Serial.println("- file deleted");
  } else {
    Serial.println("- delete failed");
  }
}

Im sure ive missed something really obvious, but I just cant unpick it and google doesnt turn up anything useful from the error code. I wondered if anyone else has had similar experience with a spiffs->littlefs webserver and bumped into the same issue or perhaps can simply see from the above what the problem is?

This is my first post on the forum, so if I've missed anything please let me know and ill edit/amend.

Thanks so much for your help!

change deletefile function to

void deleteFile(fs::FS &fs, String filename) {
  Serial.printf("Deleting file: %s\r\n", filename);
 if (!filename.startsWith("/")) filename = "/" + filename;
  if (fs.remove(filename)) {
    Serial.println("- file deleted");
  } else {
    Serial.println("- delete failed");
  }
  listDir(LittleFS, "/", 0);
}

You have some level of Debug output enabled, which prints that error [E] remove(): bad arguments message. But path is a String; with printf, %s expects a C-string. Easy enough to fix

  Serial.printf("Deleting file: %s\n", path.c_str());

Now you should be able to see what the "bad argument" is. (Also don't need "\r".)

Can't thank you enough - thank you so much for this solution!