File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed
compiler/pavexc/src/compiler Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ use guppy::graph::PackageGraph;
77use indexmap:: IndexMap ;
88
99use pavex_bp_schema:: Blueprint ;
10+ use persist_if_changed:: persist_if_changed;
1011
1112use crate :: compiler:: analyses:: application_config:: ApplicationConfig ;
1213use crate :: compiler:: analyses:: application_state:: ApplicationState ;
@@ -291,22 +292,17 @@ pub struct AppDiagnostics {
291292impl 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}
You can’t perform that action at this time.
0 commit comments