mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-23 09:33:01 +03:00
use cache for get session by id
This commit is contained in:
parent
e4f1edfc83
commit
aaba14e819
@ -31,6 +31,21 @@ impl Store {
|
||||
}
|
||||
|
||||
pub fn get_by_id(&self, session_id: &str) -> Result<Option<sessions::Session>> {
|
||||
let sessions_cache = self.sessions_cache.lock().unwrap();
|
||||
match sessions_cache.as_ref() {
|
||||
Some(sessions) => {
|
||||
for session in sessions {
|
||||
if session.id == session_id {
|
||||
return Ok(Some(session.clone()));
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
None => self.get_by_id_from_disk(session_id),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_by_id_from_disk(&self, session_id: &str) -> Result<Option<sessions::Session>> {
|
||||
let git_repository = self.git_repository.lock().unwrap();
|
||||
let reference = git_repository.find_reference(&self.project.refname())?;
|
||||
let head = git_repository.find_commit(reference.target().unwrap())?;
|
||||
|
Loading…
Reference in New Issue
Block a user