Having just looked into this a bit more, I could detect the specific DISK_ERR and automatically unmount the disk, but this causes some real problems because if you open the same file that you had open before, the filesystem doesn't need to access the disk. That means that you'll get all the way to trying to read the file before it fails.
I'll add an E.unmount() command to explicitly unmount the disk - and if you plan on pulling out the SD card while Espruino is running, you can call it after every filesystem command and it'll mean you can then remove the SD card afterwards.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Having just looked into this a bit more, I could detect the specific
DISK_ERR
and automatically unmount the disk, but this causes some real problems because if you open the same file that you had open before, the filesystem doesn't need to access the disk. That means that you'll get all the way to trying to read the file before it fails.I'll add an
E.unmount()
command to explicitly unmount the disk - and if you plan on pulling out the SD card while Espruino is running, you can call it after every filesystem command and it'll mean you can then remove the SD card afterwards.