use crate::spec::types::ParityFailure;
use std::fs;
use std::io::{self, Write};
use std::path::PathBuf;
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::{SystemTime, UNIX_EPOCH};
#[cfg(loom)]
use loom::sync::Mutex as LoomMutex;
use super::hex::*;
fn atomic_write_new(path: &std::path::Path, bytes: &[u8]) -> io::Result<()> {
let tmp_path = temp_path(path);
let mut tmp = fs::OpenOptions::new()
.write(true)
.create_new(true)
.open(&tmp_path)?;
if let Err(err) = write_and_commit(&mut tmp, &tmp_path, path, bytes) {
let _ = fs::remove_file(&tmp_path);
return Err(err);
}
Ok(())
}