| 270 | } |
| 271 | |
| 272 | pub fn store_access_record<R: ?Sized + Serialize, P: AsRef<Path>>( |
| 273 | record: &R, |
| 274 | path: P, |
| 275 | ) -> crate::Result<()> { |
| 276 | log::info!("Storing access file as '{}'", path.as_ref().display()); |
| 277 | let mut options = OpenOptions::new(); |
| 278 | options.write(true).create_new(true).mode(0o400); // Read for user, nothing for others |
| 279 | |
| 280 | let file = options.open(path.as_ref())?; |
| 281 | serde_json::to_writer_pretty(file, record)?; |
| 282 | Ok(()) |
| 283 | } |
| 284 | |
| 285 | pub fn load_worker_access_file<P: AsRef<Path>>(path: P) -> crate::Result<WorkerAccessRecord> { |
| 286 | let raw = load_and_check_version(path.as_ref())?; |