rename to lock
This commit is contained in:
parent
388d160a74
commit
f83baa0515
2 changed files with 4 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -14,7 +14,7 @@ pub struct Lock {
|
|||
}
|
||||
|
||||
impl Lock {
|
||||
pub fn new(index_directory: &Path) -> Result<Self> {
|
||||
pub fn lock(index_directory: &Path) -> Result<Self> {
|
||||
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()))
|
||||
|
|
Loading…
Reference in a new issue