wendlers / mpfshell

A simple shell based file explorer for ESP8266 Micropython based devices ⛺
MIT License
398 stars 85 forks source link

Files not closed on target during use of 'cat' command, and others. #49

Closed Aerolivier closed 5 years ago

Aerolivier commented 6 years ago

Hello.

Very sorry if I'm mistaken but it would appear that files are not closed on the actual MicroPython target device.

I'm using an ESP32-based device (the SHA2017 badge) and notice that I eventually run out of file descriptors and am unable to read more files.

mpfs [/]> cat config.json
{}
mpfs [/]> cat config.json

Failed to read file: config.json

mpfs [/]> repl

*** Exit REPL with Ctrl+] ***>

MicroPython v1.9.1-1344-g5677ea1 on 2017-08-20; SHA2017-Badge with ESP32
Type "help()" for more information.
>>> f.close()
>>> 
mpfs [/]> cat config.json
{}
mpfs [/]> cat config.json

Failed to read file: config.json

mpfs [/]>

The apparent opened file descriptor seems to originate from this line below:

https://github.com/wendlers/mpfshell/blob/e2a2d2df14bd8411059e3644a05ead6c6327583b/mp/mpfexp.py#L349

Many thanks.

skorokithakis commented 5 years ago

Fixed, thank you!