-
Notifications
You must be signed in to change notification settings - Fork 76
Description
Hi,
Let's say we run in an electrically unstable environment, and the system we are running on may be shut down unexpectedly, i.e. power loss. AND we were in the middle of the writeFile/writeFileSync. As far as I understand, the resulting storage file, on the next reboot, will consist in an incomplete JSON file. And so, all its content is lost.
OK, chances are small, but thanks to Murphy, it WILL happen.
So, would you consider securing the writing step of the file (in persistKey* functions). It could be an additional option, disabled by default.
IMO, it would be as simple as writing the ${md5(key)}.tmp file instead of md5(key), then renaming the temporary file with the actual file name.
In that case, previous content would still be safe.
Thanks!