File has around a thousand <0x00> appended to the end of nearly intact data
Nantris opened this issue · 1 comments
<0x00>
is an invalid character code as I understand it. This is the first time I've witnessed this occur.
It looks like possibly the write was interrupted, as towards the end of my file suddenly JSON ends and the <0x00>
s begin. Probably outside the scope of this module, however on the off chance this was caused by this module and not the system, here's an issue for anyone else who sees this to update.
electron-json-storage@4.1.5
Windows 7
JSON File size: ~2.5mb
Hey @slapbox ,
That is indeed super strange. I did some research and found some interesting things that seem related:
- https://stackoverflow.com/questions/10913632/streamwriter-writing-nul-characters-at-the-end-of-the-file-when-system-shutdown: Claims its known NTFS/Windows behaviour (?)
- https://stackoverflow.com/questions/27268994/why-do-i-have-a-million-null-characters-at-the-end-of-my-csv-file: I'm not very well versed in Windows programming, but it looks like if you have a stream representing the contents of your file and you call
GetBuffer()
on it, you get all the allocated bytes in the stream, where the unused ones areNUL
. I imagine this could happen if you read the file, manipulate it using the stream, and then writing it back
Assuming you can reproduce the problem, it might be worth testing different Electron versions shipping with different Node.js versions.