Merge pull request #115 from qdequele/database-path

Add accessor for database path and index path
This commit is contained in:
Clément Renault 2019-02-22 15:11:40 +01:00 committed by GitHub
commit 8701cb3a8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -293,6 +293,10 @@ impl DatabaseIndex {
Ok(view)
}
fn path(&self) -> &Path {
self.path.as_path()
}
}
impl Drop for DatabaseIndex {
@ -409,6 +413,16 @@ impl Database {
Ok(index_guard.val().update_config(config)?)
}
pub fn path(&self) -> &Path {
self.path.as_path()
}
pub fn index_path(&self, index: &str) -> Result<PathBuf, Box<Error>> {
let index_guard = self.indexes.get(index).ok_or("Index not found")?;
let path = index_guard.val().path();
Ok(path.to_path_buf())
}
}
#[cfg(test)]