Files created by SPIFFS commands are not visible in FSBrowser

I am learning ESP8266 and SPIFFS file system. There is a plugin that allows you to upload files to a flash format formatted in this file system. And there is a FSBrowser sketch that allows you to view and download flash files in the browser. It works well. When I create a file in a sketch using commands, and then in the same sketch I check what is on the flash, the file I created is visible in the list. But when I upload the sketch with FSBrowser again, this file is not visible. If I upload a sketch with checking which files are on the flash, then the file is visible and all files that are uploaded using FSBrowser or using the plugin are visible. I create a file like this:

if(!SPIFFS.exists(path1+"edit/Test2.txt")){
// Create a file
  File file = SPIFFS.open(path1+"edit/Test2.txt", "w+");
// Check if the file has been created and if it is possible to write information to it
  if(!file){
    Serial.println("Can't open file for writing");
    SPIFFS.end();
    return;
    }
  else {
    file.write("Hellow, world\n");
    file.close();
    }
}

I check for the existence of files like this:

void main_scan(String path){
    int v = scan_dir(path); 
    Serial.print("Total used in Dir \"" +path+ "\" = ");
    Serial println(v);
}

unsigned long scan_dir(String path) {
  Dir dir1 = SPIFFS.openDir(path);
  unsigned long total_size = 0;
  while (dir1.next()) {
      if (dir1.isFile()){
        Serial.print("File:\t");
        Serial.print(path + dir1.fileName());
        Serial.print("\tSize:\t"); 
        unsigned long f_size = dir1.fileSize();
        Serial.println(f_size);
        total_size += f_size;
      }
      if (dir1.isDirectory()) {
        unsigned long dsize = scan_dir(path+dir1.fileName()+"/");
        Serial.print("Dir:\t");
        Serial.print(path+dir1.fileName()+"/");
        Serial.print("\tSize:\t");
        Serial println(dsize);
        total_size += dsize;
      }
  }
  return total_size;
}

Can someone tell me why when using FSBrowser files that are created using commands are not visible? And how to make these files visible?

I wanted to clarify that by FSBrowser I meant the standard library, which is installed when installing the ESP8266 board and is among the standard examples. Her github page: Arduino/libraries/ESP8266WebServer/examples/FSBrowser at master Β· esp8266/Arduino Β· GitHub

"One important thing to consider about SPIFFS is that it does not support directories [1][2]. Thus, it means that if we create a file with the path β€œ/dir/test.txtβ€œ, it will actually create a file with name β€œ/dir/test.txt” instead of a file called β€œtest.txt” inside a β€œ/dir” folder."

Yes, I know about it. I can say that this is written in more detail here, right on the official manual page: Filesystem β€” ESP8266 Arduino Core 3.1.2-21-ga348833 documentation . And my function is very similar to the one shown in your link.
Maybe I didn't express myself correctly. But no matter how I create the file, either using "virtual" directories, that is, a slash in the file name, or I create a file without a slash in the name, the result is the same - any file created by the SPIFFS commands is not seen in FSBrowser, but is seen when scanning by my function. At the same time, if I upload a file or create a file using FSBrowser, it is visible when scanning with my function.

Since SPIFFS is deprecated, maybe you should just forget about this problem and move on to LittleFS.

1 Like

2nd that motion.

Yes, I've read that SPIFFS is deprecated and has many inconveniences. And I don’t have such problems with LittleFS, I create files and they are visible in FSBrowser. But I would like to understand the reason for such a problem: is this something I'm doing wrong or is it due to problems with outdated SPIFFS

I did not understand you

SPIFFS have been depreciated and I agree with @gfvalvo that one should use LitteFS. What you could be encountering is that ESPRESSIF broke SPIFFS with a firmware update. I have some older ESP32's that do not behave like some of the newer ESP32's because of their firmware differences.

No, I have not come across this. I recently started learning arduino and esp. And in principle, I already managed to give preference to LittleFS, but I would like to deal with SPIFFS as well.

It would be nice if someone checked this situation for themselves. Maybe I'm not creating the file correctly. Or maybe I'm not using FSBrowser correctly.

To what end? Why expend the energy to investigate a non-problem?

1 Like

To understand this is my fault or a file system problem. I want to understand all the problems of this file system.

Enjoy,

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.