mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
Both writeFile and editFile now use the same atomic write strategy: temp file in the same directory, write, rename. This ensures a failed write leaves the original file intact instead of truncated. editFile already used temp-and-rename but lost the original file's permissions because afero.TempFile creates with mode 0600. Both functions now Chmod after rename to preserve the original mode. writeFile also swallowed io.Copy errors (logged but returned HTTP 200). Fixed to return the error so the client knows the write failed.