fsync after writing Nix config to attempt to fix the flaky preserves_comment test (#448)

This commit is contained in:
Ana Hobden 2023-05-05 12:12:05 -07:00 committed by GitHub
parent 1ae77d11ee
commit 965185dcab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View file

@ -434,6 +434,10 @@ impl Action for CreateOrMergeNixConfig {
e,
))
})?;
temp_file
.sync_all()
.await
.map_err(|e| Self::error(ActionErrorKind::Sync(temp_file_path.clone(), e)))?;
tokio::fs::rename(&temp_file_path, &path)
.await
.map_err(|e| {

View file

@ -443,6 +443,8 @@ pub enum ActionErrorKind {
Open(std::path::PathBuf, #[source] std::io::Error),
#[error("Write path `{0}`")]
Write(std::path::PathBuf, #[source] std::io::Error),
#[error("Sync path `{0}`")]
Sync(std::path::PathBuf, #[source] std::io::Error),
#[error("Seek path `{0}`")]
Seek(std::path::PathBuf, #[source] std::io::Error),
#[error("Flushing `{0}`")]

View file

@ -27,7 +27,7 @@ impl std::fmt::Display for Logger {
}
}
#[derive(clap::Args, Debug)]
#[derive(clap::Args, Debug, Default)]
pub struct Instrumentation {
/// Enable debug logs, -vv for trace
#[clap(short = 'v', env = "NIX_INSTALLER_VERBOSITY", long, action = clap::ArgAction::Count, global = true)]