720cdd1d14
Replace 20 lines of manual os.open/O_EXCL/fdopen/fsync/os.replace with the existing atomic_json_write() from utils.py, which is already used by 6+ modules and handles temp-file creation, fsync, atomic replace, mode control, and owner preservation. The only novel helper (_fsync_directory) is retained — atomic_json_write does not do directory fsync. Update test_flush_write_failure_leaves_no_recovery_file to monkeypatch utils.os.replace (the new call path) instead of gateway.shutdown_flush.os.replace.