Appends one line via a single `O_APPEND` write so concurrent hook processes never interleave partial lines or lose each other's entries the way read-modify-rewrite appends do.
(path: &Path, line: &str)
| 471 | /// processes never interleave partial lines or lose each other's entries |
| 472 | /// the way read-modify-rewrite appends do. |
| 473 | pub fn append_line(path: &Path, line: &str) -> io::Result<()> { |
| 474 | if let Some(parent) = path.parent() { |
| 475 | Self::create_dir_all(parent)?; |
| 476 | } |
| 477 | reject_symlink_components(path, "private store file")?; |
| 478 | Self::open_private(path, fs::OpenOptions::new().append(true))? |
| 479 | .write_all(format!("{line}\n").as_bytes())?; |
| 480 | set_private_file_permissions(path) |
| 481 | } |
| 482 | |
| 483 | /// Opens `path` for writing, creating it if missing with owner-only |
| 484 | /// permissions applied at create time (Unix), so a fresh file never |
nothing calls this directly
no test coverage detected