drahnr / cargo-spellcheck

Checks all your documentation for spelling and grammar mistakes with hunspell and a nlprule based checker for grammar
Apache License 2.0
326 stars 33 forks source link

Assure files are written atomically #214

Closed drahnr closed 2 years ago

drahnr commented 3 years ago

Describe the bug

When hitting [CTRL] + C while writing file changes to disk.

To Reproduce

Steps to reproduce the behavior:

  1. Run cargo spellcheck fix
  2. [CTRL]+C while the Bandaids are applied + written to disk.

Expected behavior

Assure the content is written in it's entirety.

Screenshots

Please complete the following information:

Additional context

drahnr commented 3 years ago

Possible solution:

  1. do not act upon any signal directly if file writing is active
  2. store a atomic u16 to defer the signal handling
  3. evaluate after each file
  4. re-attach the original signal handler after file writing is complete