You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
Look like what is needed is enabling atomic writing (safe write). Means you write to the temp file first, and then rename it to the destination file. On Unix systems renaming is atomic operation, and Win OS has ReplaceFile() method.
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!
The text was updated successfully, but these errors were encountered: