Write the current view to disk.
(&self, view: &str)
| 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(¤t_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 |
no test coverage detected