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, 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) tokio::fs::rename(&temp_file_path, &path)
.await .await
.map_err(|e| { .map_err(|e| {

View file

@ -443,6 +443,8 @@ pub enum ActionErrorKind {
Open(std::path::PathBuf, #[source] std::io::Error), Open(std::path::PathBuf, #[source] std::io::Error),
#[error("Write path `{0}`")] #[error("Write path `{0}`")]
Write(std::path::PathBuf, #[source] std::io::Error), Write(std::path::PathBuf, #[source] std::io::Error),
#[error("Sync path `{0}`")]
Sync(std::path::PathBuf, #[source] std::io::Error),
#[error("Seek path `{0}`")] #[error("Seek path `{0}`")]
Seek(std::path::PathBuf, #[source] std::io::Error), Seek(std::path::PathBuf, #[source] std::io::Error),
#[error("Flushing `{0}`")] #[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 { pub struct Instrumentation {
/// Enable debug logs, -vv for trace /// Enable debug logs, -vv for trace
#[clap(short = 'v', env = "NIX_INSTALLER_VERBOSITY", long, action = clap::ArgAction::Count, global = true)] #[clap(short = 'v', env = "NIX_INSTALLER_VERBOSITY", long, action = clap::ArgAction::Count, global = true)]