Okay, apologies in advance for putting out a post without clearly reproducible code. But maybe someone has seen this before and can help.
I am able to write and delete to Bangle JS using the StorageFile api.
Currently my code displays ERROR on screen when my file has tried to write over an MB and failed. Thereafter it doesn't try to write anymore until the file has been dowloaded and the old file deleted. Following are bits of code that do these things
Every so often (every 1 out of 3 tries) after I have deleted the old file by calling Bangle.AppLog.clearLog() from the WebIDE - the app will try to (re)create the file, (it doesn't throw any error when calling open(...)), but fails when trying to write to the file.
>Bangle.Helper.size("fitclock.log");
0
=undefined
Trying to create new file:fitclock.log
File created: fitclock.log
Error: Error: Unable to find or create file
Trying to create new file:fitclock.log
File created: fitclock.log
As seen from the above log entries to the console, init() doesn't throw an error but the first write does.
Unfortunately, once the storage gets into this state, I cannot get Bangle to write to any file with any other name. Rebooting using "Button 1 & 2 press" doesn't help. I have to to Storage.eraseAll() to get back ability to write to file system again. All of them throw the same "Unable to find of create file" error.
>
>
>
>var f = require("Storage").open("test", "a");
=StorageFile: {
name: "test",
chunk: 1, offset: 0, addr: 0, mode: 97 }
>f.write("Testing");
Uncaught Error: Unable to find or create file
at line 1 col 18
f.write("Testing");
^
>
It is worth noting, even though StorageFile.open(...) did not throw an error, the file doesn't exist or is not recognised in the file WebIDE's file browser (ref to attached image).
I looked through the entire repository and there is only one instance of the error message Unable to find or create file and it seems to be only present here
That led me to the open issue... can't tell for sure but these two might be related?
P.S. Interesting side note... there seems to be very little disk space left for real or so Bangle thinks... So the files probably didn't get deleted and their space reclaimed? That would explain the 1/3 frequency. That certainly explains why things work after eraseAll... Hmm... what am I doing wrong with my clearLog function?
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.
Okay, apologies in advance for putting out a post without clearly reproducible code. But maybe someone has seen this before and can help.
I am able to write and delete to Bangle JS using the
StorageFile
api.Currently my code displays
ERROR
on screen when my file has tried to write over an MB and failed. Thereafter it doesn't try to write anymore until the file has been dowloaded and the old file deleted. Following are bits of code that do these thingsEvery so often (every 1 out of 3 tries) after I have deleted the old file by calling
Bangle.AppLog.clearLog()
from the WebIDE - the app will try to (re)create the file, (it doesn't throw any error when callingopen(...)
), but fails when trying to write to the file.As seen from the above log entries to the console,
init()
doesn't throw an error but the firstwrite
does.Unfortunately, once the storage gets into this state, I cannot get Bangle to write to any file with any other name. Rebooting using "Button 1 & 2 press" doesn't help. I have to to
Storage.eraseAll()
to get back ability to write to file system again. All of them throw the same "Unable to find of create file" error.It is worth noting, even though
StorageFile.open(...)
did not throw an error, the file doesn't exist or is not recognised in the file WebIDE's file browser (ref to attached image).I looked through the entire repository and there is only one instance of the error message
Unable to find or create file
and it seems to be only present hereThat led me to the open issue... can't tell for sure but these two might be related?
P.S. Interesting side note... there seems to be very little disk space left for real or so Bangle thinks... So the files probably didn't get deleted and their space reclaimed? That would explain the 1/3 frequency. That certainly explains why things work after
eraseAll
... Hmm... what am I doing wrong with myclearLog
function?1 Attachment