Possible bug with Storage.open #1367
Replies: 13 comments
-
Posted at 2019-12-17 by @fanoush Strange, I don't see open method documented here https://www.espruino.com/Reference#Storage and the write method example doesn't show that open call is needed. EDIT: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-17 by @fanoush oh maybe the \1 is chunk name or whatever (i.e each append create another numbered one)? The limit is 8 characters here https://github.com/espruino/Espruino/blob/master/src/jswrap_storage.c#L85 and 7 here https://github.com/espruino/Espruino/blob/master/src/jswrap_storage.c#L294 EDIT: oh yes, here it is clear https://github.com/espruino/Espruino/blob/master/src/jswrap_storage.c#L612 Also this may bite someone https://github.com/espruino/Espruino/blob/master/src/jswrap_storage.c#L395 "you should not write character code 255 ( |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-17 by @gfwilliams
Yes, that's expected. As you write more, you'll get a I'll add something to the
The generated docs match the current stable firmware release - and
It might - but honestly if you're writing binary files rather than text you're probably more likely to have read the docs and seen that. If you can think of other solutions for this I'm happy to look at them, but this seemed like the most stable way of handling 'growing' a file. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-17 by @fanoush I see now that it is not just some comment but part of documentation, so that's fine. It is just confusion caused by not seeing generated documentation yet. FF could be solved by having some escape character and then escaping it and some FF replacement value similar to e.g. what SLIP does. But that would work only if you read it by characters and make a copy, not when results point directly to flash data. If these are meant to be text files it is probably not worth it. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-17 by @gfwilliams
Good point. If it becomes an issue then that could be added. Potentially there could also be a check & exception in |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-17 by feugy Thanks for the clarification folks. This final character makes Puck.eval('require("Storage").list()') will fail on:
Having chosen an octal escape sequence make it hard to (de)serialize. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-17 by feugy To give a bit of context: I would like the ability to list files present on the board. I've mitigated the encoding issue: // this is on the BangleApp:
Puck.eval('require("Storage").list().map(encodeURIComponent)', (files,err) => {
if (files===null) return reject(err || "");
files = files.map(decodeURIComponent)
console.log("listFiles", files);
resolve(files)
}); |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-07 by @gfwilliams Thanks for the update. I'm surprised this is the first time it's been hit. It looks like I guess the solution for now might be to add a regex to Issues filed at espruino/Espruino#1737 and espruino/EspruinoWebTools#1 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-07 by feugy I lost quite some time trying to replace octal sequence with regex... with no luck, hence why I used encodeURIComponent instead. I'll be very interested to learn about the solution, would some regex wizard lit my lamp. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-08 by @allObjects ...regex lamps are domed to glow dim... sorry, myself not much more than smoldering regex wick.. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-22 by PiOfThings @gfwilliams just to clarify, once the file increases in size and starts getting the shard marker in the end we have to use the shard marker in the name when we do a read, correct?
I am getting this behaviour, I am still on the default beta version firmware that came with my KS Beta unit. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-23 by @gfwilliams
No... If you use |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-23 by PiOfThings @gfwilliams thanks... works perfectly with |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-17 by feugy
Hi there!
Before opening a bug on the tracker, I wanted to double check this behaviour.
This code opens a file in append mode, and writes some text in it.
this gives:
This
\1
at the end: is it expected?Beta Was this translation helpful? Give feedback.
All reactions