MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / write_current_view

Method write_current_view

atomic-repository/src/repository/mod.rs:756–772  ·  view source on GitHub ↗

Write the current view to disk.

(&self, view: &str)

Source from the content-addressed store, hash-verified

754
755 /// Write the current view to disk.
756 fn write_current_view(&self, view: &str) -> Result<(), RepositoryError> {
757 use std::io::Write;
758
759 let current_path = self.dot_dir.join("current_view");
760 let mut temp = tempfile::NamedTempFile::new_in(&self.dot_dir)?;
761 temp.as_file_mut().write_all(view.as_bytes())?;
762 temp.as_file_mut().write_all(b"\n")?;
763 temp.as_file().sync_all()?;
764 temp.persist(&current_path).map_err(|error| {
765 RepositoryError::Io(std::io::Error::other(format!(
766 "failed to persist current view: {}",
767 error
768 )))
769 })?;
770 self.sync_dot_dir()?;
771 Ok(())
772 }
773
774 /// Make prior atomic renames/removals in `.atomic` durable before a
775 /// coupled database transition is allowed to advance. Directory fsync is

Calls 2

sync_dot_dirMethod · 0.80
as_bytesMethod · 0.45

Tested by

no test coverage detected