Skip to content

Secure writing #94

@cupill

Description

@cupill

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!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions