How to read file list in a specific folder using API?

What is the problem?

In a specific subfolder under the local folder, I use the API to read the list of files from the server, but the server responds only to the list at first startup (boot), not the refreshed list.

I am using OctoDash by selecting gcode from the file menu. To use a USB memory stick, I installed usbmount and set the "uploads/STICK" folder as the mount point. I checked that the gcode files in the USB memory mounted using SSH are read normally.

However, when I remove or insert a USB memory stick and check the file list of OctoDash, it does not refresh normally. I created a folder called "ROOM" in the uploads folder for confirmation, and it is the same when requesting a file list with an API request. In the Web UI, the file list is displayed normally using the refresh button.

Reproduction process

  1. create "ROOM" folder, add three gcodes and restart OctoPrint

  2. API requests using Edge's Devtool

  3. Delete one gcode file via web ui

  4. API request using Edge's Devtool to read a list of files
    Include recursive=true&force=true key


    Not include recursive=true&force=true key

    List of files with deleted gcode responsed

  5. Add two gcode file to "ROOM" folder

  6. API request using Edge's Devtool to read a list of files


    Not a list of 4 files, but a list of files not updated (3) responses

  7. When I make an API request with /api/files?recursive=true&force=true, it responds with a list of 4 gcode files.

If I use the octoprint web ui, there is no problem because the web ui gets the entire list of folders and files every time I refresh (api/files?recursive=true&force=true). But when I use octodash, it requests list of files by specific folder via API "api/files/local/ROOM". When reading the list of files by specific folder like this, it seems to only receive the list when the octoprint server first boots, which is not updated.

Am I using the wrong API request format? Is there a specific format that makes an API request to get a list of files by directly examining a specific folder, such as a subfolder?

What did you already try to solve it?

  1. Include recursive=true and force=true keys in API request
  2. Tried mounting the usb memory stick to an arbitrary watched folder - I confirmed that it was automatically moved to the uploads folder, but it seems to be a problem because all gcode files stored in the usb memory are moved instead of selecting a specific gcode file.

Have you tried running in safe mode?

Yes, there is not much difference.

Did running in safe mode solve the problem?

No

Additional information about your setup

OctoPrint 1.8.6
OctoPi 0.18.0
OctoDash 2.3.1
Raspberry Pi 3 Model B Rev 1.2
Windows 10
Edge Web Browser
Installed Plugin: DisplayLayerProgress Plugin, FileManager, OctoDash Companion, Preheat Button, PrintTimeGenius Plugin, Slicer Thumbnails

I think the request looks correct, this might be a bug. I need to validate this is not specific to you and is reproducible as you describe though as it seems like that would be a huge oversight.

This is intended as the watched folder is suppose to be a "drop box" that gets picked up and processed.

Just tested strictly with a browser and I'm able to get the sub-folder file list updates without issue, so I'm wondering if this is related to some kind of caching. I created a sub-folder, moved some files into that sub-folder and did a get request just purely using the browser in another tab to http://192.168.0.118/api/files/local/Test received a list of the files as expected. Deleted a file in the main UI and went to my other tab and clicked refresh button and got an updated json response with the file removed.

Thanks for testing.

That's strange. I'll test it again when I get back to the office.

In the meantime, I kept inserting and removing USB to test the USB memory stick, and I have pressed the refresh button frequently. Could such an action cause problems with the file list cache? Isn't the cache initialized (override, clean?) with the refresh button?

For a certain period of time, whenever the refresh button was pressed, the folder size and file list alternately changed between old and new. I know that server analyzes the gcode in the folders and saves it to a json file. It doesn't seem to be processed as soon as I save the file because the analysis takes time. In the meantime, can the list of files go back and forth between old and new?

The same symptoms were repeated, so I newly installed octopi. After reinstalling, it works normally, so I'm still watching.

maybe a plugin was interrupting the API somehow...