Skip to content

Commit a147a55

Browse files
chore: Don't change the mtime of the diagnostic file if there were no changes
1 parent bc2b9aa commit a147a55

File tree

1 file changed

+7
-11
lines changed
  • compiler/pavexc/src/compiler

1 file changed

+7
-11
lines changed

compiler/pavexc/src/compiler/app.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use guppy::graph::PackageGraph;
77
use indexmap::IndexMap;
88

99
use pavex_bp_schema::Blueprint;
10+
use persist_if_changed::persist_if_changed;
1011

1112
use crate::compiler::analyses::application_config::ApplicationConfig;
1213
use crate::compiler::analyses::application_state::ApplicationState;
@@ -291,22 +292,17 @@ pub struct AppDiagnostics {
291292
impl AppDiagnostics {
292293
/// Save all diagnostics in a single file.
293294
pub fn persist_flat(&self, filepath: &Path) -> Result<(), anyhow::Error> {
294-
let file = fs_err::OpenOptions::new()
295-
.create(true)
296-
.write(true)
297-
.truncate(true)
298-
.open(filepath)?;
299-
let mut file = BufWriter::new(file);
300-
295+
let mut buffer = Vec::new();
301296
for handler_graphs in &self.handlers {
302297
for handler_graph in handler_graphs {
303-
file.write_all(handler_graph.as_bytes())?;
298+
buffer.write_all(handler_graph.as_bytes())?;
304299
// Add a newline between graphs for readability
305-
file.write_all("\n".as_bytes())?;
300+
buffer.write_all("\n".as_bytes())?;
306301
}
307302
}
308-
file.write_all(self.application_state.as_bytes())?;
309-
file.flush()?;
303+
buffer.write_all(self.application_state.as_bytes())?;
304+
305+
persist_if_changed(filepath, &buffer)?;
310306
Ok(())
311307
}
312308
}

0 commit comments

Comments
 (0)