diff --git a/src/index/io.rs b/src/index/io.rs index a97fdf5..6357468 100644 --- a/src/index/io.rs +++ b/src/index/io.rs @@ -20,7 +20,7 @@ impl Index { let mut index = Index::new(repository_path); index.save()?; } - let lock = Lock::new(repository_path)?; + let lock = Lock::lock(repository_path)?; let index = Index::load_from_file(&Index::index_file_path_for_repository_path(repository_path))?; lock.release()?; log::debug!( @@ -34,7 +34,7 @@ impl Index { pub fn save(&mut self) -> Result<()> { let lock_id = Uuid::new_v4(); - let lock = Lock::new(&self.index_directory()?)?; + let lock = Lock::lock(&self.index_directory()?)?; if self.index_file_path().exists() { let index = Index::load_from_file(&Index::index_file_path_for_repository_path(&self.index_directory()?))?; self.merge_items_by_file_id(index.items_by_file_id); diff --git a/src/index/lock.rs b/src/index/lock.rs index 9585614..8967747 100644 --- a/src/index/lock.rs +++ b/src/index/lock.rs @@ -14,7 +14,7 @@ pub struct Lock { } impl Lock { - pub fn new(index_directory: &Path) -> Result { + pub fn lock(index_directory: &Path) -> Result { let mut buffer = [0u8; 16]; OsRng.fill_bytes(&mut buffer); let id = Uuid::from_bytes(buffer); @@ -101,7 +101,7 @@ mod must { fn be_released_when_dropped() -> Result<()> { let temp_dir = tempfile::tempdir()?; { - let _lock = Lock::new(&temp_dir.path()); + let _lock = Lock::lock(&temp_dir.path()); } let entries = fs::read_dir(temp_dir.into_path())? .map(|res| res.map(|e| e.path()))