mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-09-12 21:57:19 -04:00
Windows CI caught the atomic replace failing with UnauthorizedAccessException: renaming over a file is denied while another handle holds it open, however generously that handle shares the file. In production the CLI, a second GUI instance or a virus scanner can each hold Settings.json for a moment, so retry the replace a few times before letting the caller see the failure. The previous File.WriteAllText threw on the same holds, so this is strictly more forgiving. ExternalReaderNeverSeesAPartiallyWrittenFile keeps a handle open almost continuously, which no retry budget can outlast on Windows, so restrict it to unix where it actually tests write atomicity. Write_SurvivesATemporarilyUnwritableDirectory covers the retry instead by revoking write permission on the containing directory. Co-authored-by: rmcrackan <rmcrackan@gmail.com>