mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
fix: atomically write to static file configuration file (#8666)
This commit is contained in:
@ -181,27 +181,29 @@ impl StaticFileProviderRW {
|
||||
}
|
||||
}
|
||||
|
||||
// Commits offsets and new user_header to disk
|
||||
self.writer.commit().map_err(|e| ProviderError::NippyJar(e.to_string()))?;
|
||||
if self.writer.is_dirty() {
|
||||
// Commits offsets and new user_header to disk
|
||||
self.writer.commit().map_err(|e| ProviderError::NippyJar(e.to_string()))?;
|
||||
|
||||
if let Some(metrics) = &self.metrics {
|
||||
metrics.record_segment_operation(
|
||||
self.writer.user_header().segment(),
|
||||
StaticFileProviderOperation::CommitWriter,
|
||||
Some(start.elapsed()),
|
||||
if let Some(metrics) = &self.metrics {
|
||||
metrics.record_segment_operation(
|
||||
self.writer.user_header().segment(),
|
||||
StaticFileProviderOperation::CommitWriter,
|
||||
Some(start.elapsed()),
|
||||
);
|
||||
}
|
||||
|
||||
debug!(
|
||||
target: "provider::static_file",
|
||||
segment = ?self.writer.user_header().segment(),
|
||||
path = ?self.data_path,
|
||||
duration = ?start.elapsed(),
|
||||
"Commit"
|
||||
);
|
||||
|
||||
self.update_index()?;
|
||||
}
|
||||
|
||||
debug!(
|
||||
target: "provider::static_file",
|
||||
segment = ?self.writer.user_header().segment(),
|
||||
path = ?self.data_path,
|
||||
duration = ?start.elapsed(),
|
||||
"Commit"
|
||||
);
|
||||
|
||||
self.update_index()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user