Merge pull request #1286 from gitbutlerapp/deps-refactor

Deps refactor
This commit is contained in:
Nikita Galaiko 2023-10-04 16:07:35 +02:00 committed by GitHub
commit 65a0979649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 150 additions and 193 deletions

View File

@ -33,13 +33,9 @@ impl App {
.context("failed to find project")?;
let user = users_storage.get().context("failed to get user")?;
let gb_repository = gb_repository::Repository::open(
&local_data_dir,
&project.id,
projects_storage,
user.as_ref(),
)
.context("failed to open repository")?;
let gb_repository =
gb_repository::Repository::open(&local_data_dir, &project, user.as_ref())
.context("failed to open repository")?;
let db_path = std::path::Path::new(&local_data_dir).join("database.sqlite3");
let database = database::Database::try_from(&db_path).context("failed to open database")?;

View File

@ -86,20 +86,6 @@ impl App {
Ok(())
}
fn gb_repository(
&self,
project_id: &str,
user: Option<&users::User>,
) -> Result<gb_repository::Repository> {
gb_repository::Repository::open(
self.local_data_dir.clone(),
project_id,
self.projects_storage.clone(),
user,
)
.context("failed to open repository")
}
fn gb_project(&self, project_id: &str) -> Result<projects::Project> {
self.projects_storage
.get_project(project_id)
@ -179,8 +165,7 @@ impl App {
Some(project) => {
let gb_repository = match gb_repository::Repository::open(
self.local_data_dir.clone(),
id,
self.projects_storage.clone(),
&project,
self.users_storage.get()?.as_ref(),
) {
Ok(repo) => Ok(Some(repo)),
@ -242,9 +227,15 @@ impl App {
.context("failed to get session")?
.context("session not found")?;
let user = self.users_storage.get()?;
let gb_repo = self
.gb_repository(project_id, user.as_ref())
.context("failed to open repository")?;
let project = self
.projects_storage
.get_project(project_id)
.context("failed to get project")?
.ok_or_else(|| anyhow::anyhow!("project {} not found", project_id))?;
let gb_repo =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open gb repository")?;
let session_reader =
sessions::Reader::open(&gb_repo, &session).context("failed to open session reader")?;
session_reader
@ -265,7 +256,9 @@ impl App {
let project = self.gb_project(project_id)?;
let project_repository = project_repository::Repository::open(&project)?;
let user = self.users_storage.get()?;
let gb_repo = self.gb_repository(project_id, user.as_ref())?;
let gb_repo =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open gb repository")?;
let current_session = gb_repo.get_or_create_current_session()?;
let current_session_reader = sessions::Reader::open(&gb_repo, &current_session)?;
let target_reader = target::Reader::new(&current_session_reader);
@ -299,7 +292,9 @@ impl App {
pub fn upsert_bookmark(&self, bookmark: &bookmarks::Bookmark) -> Result<()> {
let user = self.users_storage.get()?;
let gb_repository = self.gb_repository(&bookmark.project_id, user.as_ref())?;
let project = self.gb_project(&bookmark.project_id)?;
let gb_repository =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())?;
let writer = bookmarks::Writer::new(&gb_repository).context("failed to open writer")?;
writer.write(bookmark).context("failed to write bookmark")?;
@ -411,8 +406,10 @@ impl App {
project_id: &str,
) -> Result<Vec<virtual_branches::RemoteBranch>> {
let user = self.users_storage.get()?;
let gb_repository = self.gb_repository(project_id, user.as_ref())?;
let project = self.gb_project(project_id)?;
let gb_repository =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open gb repo")?;
let project_repository = project_repository::Repository::open(&project)
.context("failed to open project repository")?;
virtual_branches::list_remote_branches(&gb_repository, &project_repository)
@ -449,7 +446,10 @@ impl App {
pub fn git_gb_push(&self, project_id: &str) -> Result<()> {
let user = self.users_storage.get()?;
let gb_repository = self.gb_repository(project_id, user.as_ref())?;
let project = self.gb_project(project_id)?;
let gb_repository =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open gb repo")?;
gb_repository.push(user.as_ref())
}

View File

@ -25,7 +25,7 @@ impl<'writer> BookmarksWriter<'writer> {
)?;
tracing::debug!(
project_id = self.repository.project_id,
project_id = self.repository.project.id,
timestamp_ms = bookmark.timestamp_ms,
"wrote bookmark",
);

View File

@ -32,7 +32,7 @@ impl<'writer> DeltasWriter<'writer> {
.write_string(&format!("session/deltas/{}", path.display()), &raw_deltas)?;
tracing::debug!(
project_id = self.repository.project_id,
project_id = self.repository.project.id,
path = %path.display(),
"wrote deltas"
);
@ -52,7 +52,7 @@ impl<'writer> DeltasWriter<'writer> {
.write_string(&format!("session/wd/{}", path.display()), contents)?;
tracing::debug!(
project_id = self.repository.project_id,
project_id = self.repository.project.id,
path = %path.display(),
"wrote session wd file"
);

View File

@ -23,8 +23,7 @@ use crate::{
};
pub struct Repository {
pub project_id: String,
project_store: projects::Storage,
pub project: projects::Project,
pub git_repository: git::Repository,
lock_file: std::fs::File,
}
@ -44,29 +43,19 @@ pub enum Error {
impl Repository {
pub fn open<P: AsRef<std::path::Path>>(
root: P,
project_id: &str,
project_store: projects::Storage,
project: &projects::Project,
user: Option<&users::User>,
) -> Result<Self, Error> {
let project = project_store
.get_project(project_id)
.context("failed to get project")
.map_err(Error::Other)?;
if project.is_none() {
return Err(Error::ProjectNotFound);
}
let project = project.unwrap();
let project_objects_path = std::path::Path::new(&project.path).join(".git/objects");
if !project_objects_path.exists() {
return Err(Error::ProjectPathNotFound(project_objects_path));
}
let path = root.as_ref().join("projects").join(project_id.clone());
let path = root.as_ref().join("projects").join(&project.id);
let lock_path = root
.as_ref()
.join("projects")
.join(format!("{}.lock", project_id));
.join(format!("{}.lock", project.id));
if path.exists() {
let git_repository = git::Repository::open(path.clone())
.with_context(|| format!("{}: failed to open git repository", path.display()))?;
@ -76,9 +65,8 @@ impl Repository {
.map_err(Error::Git)?;
Result::Ok(Self {
project_id: project_id.to_string(),
project: project.clone(),
git_repository,
project_store,
lock_file: File::create(lock_path).context("failed to create lock file")?,
})
} else {
@ -96,9 +84,8 @@ impl Repository {
.context("failed to add disk alternate")?;
let gb_repository = Self {
project_id: project_id.to_string(),
project: project.clone(),
git_repository,
project_store,
lock_file: File::create(lock_path).context("failed to create lock file")?,
};
@ -106,7 +93,7 @@ impl Repository {
.migrate(&project)
.context("failed to migrate")?
{
tracing::info!(project_id = gb_repository.project_id, "repository migrated");
tracing::info!(project_id = gb_repository.project.id, "repository migrated");
return Result::Ok(gb_repository);
}
@ -128,17 +115,10 @@ impl Repository {
}
pub fn get_project_id(&self) -> &str {
&self.project_id
&self.project.id
}
fn remote(&self, user: Option<&users::User>) -> Result<Option<(git::Remote, String)>> {
let project = self
.project_store
.get_project(&self.project_id)
.context("failed to get project")?
.ok_or(anyhow!("project not found"))?;
let project = project.as_ref();
// only push if logged in
let access_token = match user {
Some(user) => user.access_token.clone(),
@ -146,7 +126,7 @@ impl Repository {
};
// only push if project is connected
let remote_url = match project.api {
let remote_url = match self.project.api {
Some(ref api) => api.git_url.clone(),
None => return Ok(None),
};
@ -173,7 +153,7 @@ impl Repository {
let mut callbacks = git2::RemoteCallbacks::new();
callbacks.push_update_reference(move |refname, message| {
tracing::debug!(
project_id = self.project_id,
project_id = self.project.id,
refname,
message,
"pulling reference"
@ -182,7 +162,7 @@ impl Repository {
});
callbacks.push_transfer_progress(move |one, two, three| {
tracing::debug!(
project_id = self.project_id,
project_id = self.project.id,
"transferred {}/{}/{} objects",
one,
two,
@ -204,7 +184,7 @@ impl Repository {
))?;
tracing::info!(
project_id = self.project_id,
project_id = self.project.id,
remote = %remote.url()?.unwrap(),
"gb repo fetched",
);
@ -222,7 +202,7 @@ impl Repository {
let mut callbacks = git2::RemoteCallbacks::new();
callbacks.push_update_reference(move |refname, message| {
tracing::debug!(
project_id = self.project_id,
project_id = self.project.id,
refname,
message,
"pushing reference"
@ -231,7 +211,7 @@ impl Repository {
});
callbacks.push_transfer_progress(move |one, two, three| {
tracing::debug!(
project_id = self.project_id,
project_id = self.project.id,
"transferred {}/{}/{} objects",
one,
two,
@ -245,7 +225,7 @@ impl Repository {
let headers = &[auth_header.as_str()];
push_options.custom_headers(headers);
let remote_refspec = format!("refs/heads/current:refs/heads/{}", self.project_id);
let remote_refspec = format!("refs/heads/current:refs/heads/{}", self.project.id);
// Push to the remote
remote
@ -255,7 +235,7 @@ impl Repository {
remote.url()?.unwrap()
))?;
tracing::info!(project_id = self.project_id, remote = %remote.url()?.unwrap(), "gb repository pushed");
tracing::info!(project_id = self.project.id, remote = %remote.url()?.unwrap(), "gb repository pushed");
Ok(())
}
@ -362,7 +342,7 @@ impl Repository {
.context("failed to write session")?;
tracing::info!(
project_id = self.project_id,
project_id = self.project.id,
session_id = session.id,
"created new session"
);
@ -381,15 +361,7 @@ impl Repository {
match sessions::Session::try_from(reader) {
Result::Ok(session) => Ok(session),
Err(sessions::SessionError::NoSession) => {
let project = self
.project_store
.get_project(&self.project_id)
.context("failed to get project")?;
if project.is_none() {
return Err(anyhow!("project does not exist"));
}
let project = project.unwrap();
let project_repository = project_repository::Repository::open(&project)
let project_repository = project_repository::Repository::open(&self.project)
.context("failed to open project repository")?;
let session = self
.create_current_session(&project_repository)
@ -410,18 +382,9 @@ impl Repository {
return Ok(None);
}
let project = self
.project_store
.get_project(&self.project_id)
.context("failed to get project")?;
if project.is_none() {
return Err(anyhow!("project not found"));
}
let project = project.unwrap();
let current_session = current_session.unwrap();
let current_session = self.flush_session(
&project_repository::Repository::open(&project)?,
&project_repository::Repository::open(&self.project)?,
&current_session,
user,
)?;
@ -476,7 +439,7 @@ impl Repository {
write_gb_commit(tree_id, self, user).context("failed to write gb commit")?;
tracing::info!(
project_id = self.project_id,
project_id = self.project.id,
session_id = session.id,
%commit_oid,
"flushed session"
@ -653,7 +616,7 @@ fn build_wd_tree(
Result::Ok(reader::Content::UTF8(content)) => content,
Result::Ok(reader::Content::Large) => {
tracing::error!(
project_id = gb_repository.project_id,
project_id = gb_repository.project.id,
path = %abs_path.display(),
"large file in session working directory"
);
@ -661,7 +624,7 @@ fn build_wd_tree(
}
Result::Ok(reader::Content::Binary) => {
tracing::error!(
project_id = gb_repository.project_id,
project_id = gb_repository.project.id,
path = %abs_path.display(),
"binary file in session working directory"
);
@ -669,7 +632,7 @@ fn build_wd_tree(
}
Err(error) => {
tracing::error!(
project_id = gb_repository.project_id,
project_id = gb_repository.project.id,
path = %abs_path.display(),
?error,
"failed to read file"
@ -838,7 +801,7 @@ fn add_wd_path(
// TODO: size limit should be configurable
let blob = if metadata.len() > 100_000_000 {
tracing::warn!(
project_id = gb_repository.project_id,
project_id = gb_repository.project.id,
path = %file_path.display(),
"file too big"
);

View File

@ -201,7 +201,7 @@ fn test_remote_syncronization() -> Result<()> {
let user = suite.sign_in();
// create first local project, add files, deltas and flush a session
let case_one = suite.new_case_with_files(HashMap::from([(
let mut case_one = suite.new_case_with_files(HashMap::from([(
path::PathBuf::from("test.txt"),
"Hello World",
)]));
@ -212,6 +212,7 @@ fn test_remote_syncronization() -> Result<()> {
api: Some(api_project.clone()),
..Default::default()
})?;
case_one.refresh();
let writer = deltas::Writer::new(&case_one.gb_repository);
writer.write(
@ -225,7 +226,7 @@ fn test_remote_syncronization() -> Result<()> {
case_one.gb_repository.push(Some(&user)).unwrap();
// create second local project, fetch it and make sure session is there
let case_two = suite.new_case();
let mut case_two = suite.new_case();
suite
.projects_storage
.update_project(&projects::UpdateRequest {
@ -233,6 +234,7 @@ fn test_remote_syncronization() -> Result<()> {
api: Some(api_project.clone()),
..Default::default()
})?;
case_two.refresh();
case_two.gb_repository.fetch(Some(&user))?;
@ -282,7 +284,7 @@ fn test_remote_sync_order() -> Result<()> {
let suite = Suite::default();
let case_one = suite.new_case();
let mut case_one = suite.new_case();
suite
.projects_storage
.update_project(&projects::UpdateRequest {
@ -290,8 +292,9 @@ fn test_remote_sync_order() -> Result<()> {
api: Some(api_project.clone()),
..Default::default()
})?;
case_one.refresh();
let case_two = suite.new_case();
let mut case_two = suite.new_case();
suite
.projects_storage
.update_project(&projects::UpdateRequest {
@ -299,6 +302,7 @@ fn test_remote_sync_order() -> Result<()> {
api: Some(api_project.clone()),
..Default::default()
})?;
case_two.refresh();
let user = suite.sign_in();

View File

@ -39,7 +39,7 @@ impl<'writer> SessionWriter<'writer> {
if current_session_id.is_some() && current_session_id.as_ref() != Some(&session.id) {
return Err(anyhow!(
"{}: can not open writer for {} because a writer for {} is still open",
self.repository.project_id,
self.repository.project.id,
session.id,
current_session_id.unwrap()
));

View File

@ -66,14 +66,10 @@ impl Suite {
.expect("failed to add project");
let project_repository = project_repository::Repository::try_from(&project)
.expect("failed to create project repository");
let gb_repository = gb_repository::Repository::open(
&self.local_app_data,
&project.id,
self.projects_storage.clone(),
None,
)
.expect("failed to open gb repository");
let gb_repository = gb_repository::Repository::open(&self.local_app_data, &project, None)
.expect("failed to open gb repository");
Case {
suite: self,
project_repository,
project,
gb_repository,
@ -81,12 +77,29 @@ impl Suite {
}
}
pub struct Case {
pub struct Case<'a> {
suite: &'a Suite,
pub project_repository: project_repository::Repository,
pub gb_repository: gb_repository::Repository,
pub project: projects::Project,
}
impl Case<'_> {
pub fn refresh(&mut self) {
self.project = self
.suite
.projects_storage
.get_project(&self.project.id)
.expect("failed to get project")
.expect("project not found");
self.project_repository = project_repository::Repository::try_from(&self.project)
.expect("failed to create project repository");
self.gb_repository =
gb_repository::Repository::open(&self.suite.local_app_data, &self.project, None)
.expect("failed to open gb repository");
}
}
pub fn test_database() -> database::Database {
let path = temp_dir().join("test.db");
database::Database::try_from(&path).unwrap()

View File

@ -115,7 +115,10 @@ impl Controller {
.try_into()
.context("failed to open project repository")?;
let user = self.users_storage.get().context("failed to get user")?;
let gb_repository = self.open_gb_repository(project_id, user.as_ref())?;
let gb_repository =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open gitbutler repository")
.map_err(Error::Other)?;
super::is_remote_branch_mergeable(&gb_repository, &project_repository, branch_name)
.map_err(Error::Other)
}
@ -135,7 +138,10 @@ impl Controller {
.try_into()
.context("failed to open project repository")?;
let user = self.users_storage.get().context("failed to get user")?;
let gb_repository = self.open_gb_repository(project_id, user.as_ref())?;
let gb_repository =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open gitbutler repository")
.map_err(Error::Other)?;
super::is_virtual_branch_mergeable(&gb_repository, &project_repository, branch_id)
.map_err(Error::Other)
}
@ -229,7 +235,10 @@ impl Controller {
.try_into()
.context("failed to open project repository")?;
let user = self.users_storage.get().context("failed to get user")?;
let gb_repository = self.open_gb_repository(project_id, user.as_ref())?;
let gb_repository =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open gitbutler repository")
.map_err(Error::Other)?;
let base_branch = super::get_base_branch_data(&gb_repository, &project_repository)?;
if let Some(branch) = base_branch {
Ok(Some(self.proxy_base_branch(branch).await))
@ -277,7 +286,10 @@ impl Controller {
let user = self.users_storage.get().context("failed to get user")?;
let gb_repository = self.open_gb_repository(project_id, user.as_ref())?;
let gb_repository =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open gitbutler repository")
.map_err(Error::Other)?;
let target = super::set_base_branch(
&gb_repository,
&project_repository,
@ -484,7 +496,10 @@ impl Controller {
.try_into()
.context("failed to open project repository")?;
let user = self.users_storage.get().context("failed to get user")?;
let gb_repository = self.open_gb_repository(project_id, user.as_ref())?;
let gb_repository =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open gitbutler repository")
.map_err(Error::Other)?;
super::integration::verify_branch(&gb_repository, &project_repository).map_err(
|e| match e {
super::integration::VerifyError::DetachedHead => Error::DetachedHead,
@ -505,21 +520,6 @@ impl Controller {
action()
}
fn open_gb_repository(
&self,
project_id: &str,
user: Option<&users::User>,
) -> Result<gb_repository::Repository, Error> {
gb_repository::Repository::open(
self.local_data_dir.clone(),
project_id,
self.projects_storage.clone(),
user,
)
.context("failed to open repository")
.map_err(Error::Other)
}
async fn proxy_base_branch(&self, target: super::BaseBranch) -> super::BaseBranch {
super::BaseBranch {
recent_commits: join_all(

View File

@ -1570,6 +1570,7 @@ fn test_update_target_with_conflicts_in_vbranches() -> Result<()> {
project_repository,
gb_repository,
project,
..
} = Suite::default().new_case();
let current_session = gb_repository.get_or_create_current_session()?;
@ -1972,6 +1973,7 @@ fn test_unapply_ownership_full_file() -> Result<()> {
project_repository,
gb_repository,
project,
..
} = Suite::default().new_case();
set_test_target(&gb_repository, &project_repository)?;

View File

@ -68,19 +68,6 @@ impl HandlerInner {
let user = self.user_storage.get()?;
let gb_repo = gb_repository::Repository::open(
self.local_data_dir.clone(),
project_id,
self.project_storage.clone(),
user.as_ref(),
)
.context("failed to open repository")?;
let sessions_before_fetch = gb_repo
.get_sessions_iterator()?
.filter_map(|s| s.ok())
.collect::<Vec<_>>();
// mark fetching
self.project_storage
.update_project(&projects::UpdateRequest {
@ -98,6 +85,15 @@ impl HandlerInner {
.context("failed to get project")?
.ok_or_else(|| anyhow::anyhow!("project not found"))?;
let gb_repo =
gb_repository::Repository::open(self.local_data_dir.clone(), &project, user.as_ref())
.context("failed to open repository")?;
let sessions_before_fetch = gb_repo
.get_sessions_iterator()?
.filter_map(|s| s.ok())
.collect::<Vec<_>>();
let fetch_result = if let Err(error) = gb_repo.fetch(user.as_ref()) {
tracing::error!(project_id, ?error, "failed to fetch gitbutler data");
projects::FetchResult::Error {

View File

@ -73,16 +73,6 @@ impl HandlerInner {
let user = self.user_storage.get()?;
let gb_repo = gb_repository::Repository::open(
self.local_data_dir.clone(),
project_id,
self.project_storage.clone(),
user.as_ref(),
)
.context("failed to open repository")?;
let default_target = gb_repo.default_target()?.context("target not set")?;
// mark fetching
self.project_storage
.update_project(&projects::UpdateRequest {
@ -100,6 +90,11 @@ impl HandlerInner {
.context("failed to get project")?
.ok_or_else(|| anyhow::anyhow!("project not found"))?;
let gb_repo =
gb_repository::Repository::open(self.local_data_dir.clone(), &project, user.as_ref())
.context("failed to open repository")?;
let default_target = gb_repo.default_target()?.context("target not set")?;
let key = match &project.preferred_key {
projects::AuthKey::Generated => {
let private_key = self.keys_controller.get_or_create()?;

View File

@ -44,13 +44,9 @@ impl Handler {
let user = self.user_store.get()?;
let gb_repo = gb_repository::Repository::open(
&self.local_data_dir,
project_id,
self.project_store.clone(),
user.as_ref(),
)
.context("failed to open repository")?;
let gb_repo =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open repository")?;
let session = gb_repo
.flush_session(

View File

@ -72,14 +72,14 @@ impl Handler {
pub fn reindex(&self, project_id: &str) -> Result<Vec<events::Event>> {
let user = self.user_store.get()?;
let project = self
.project_store
.get_project(project_id)?
.context(format!("failed to get project with id {}", project_id))?;
let gb_repository = gb_repository::Repository::open(
self.local_data_dir.clone(),
project_id,
self.project_store.clone(),
user.as_ref(),
)
.context("failed to open repository")?;
let gb_repository =
gb_repository::Repository::open(self.local_data_dir.clone(), &project, user.as_ref())
.context("failed to open repository")?;
let sessions_iter = gb_repository.get_sessions_iterator()?;
let mut events = vec![];
@ -95,14 +95,14 @@ impl Handler {
session: &sessions::Session,
) -> Result<Vec<events::Event>> {
let user = self.user_store.get()?;
let project = self
.project_store
.get_project(project_id)?
.context(format!("failed to get project with id {}", project_id))?;
let gb_repository = gb_repository::Repository::open(
self.local_data_dir.clone(),
project_id,
self.project_store.clone(),
user.as_ref(),
)
.context("failed to open repository")?;
let gb_repository =
gb_repository::Repository::open(self.local_data_dir.clone(), &project, user.as_ref())
.context("failed to open repository")?;
// first of all, index session for searching. searhcer keeps it's own state to
// decide if the actual indexing needed

View File

@ -98,13 +98,9 @@ impl Handler {
let user = self.user_store.get().context("failed to get user")?;
let gb_repository = gb_repository::Repository::open(
&self.local_data_dir,
project_id,
self.project_store.clone(),
user.as_ref(),
)
.context("failed to open gb repository")?;
let gb_repository =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open gb repository")?;
// If current session's branch is not the same as the project's head, flush it first.
if let Some(session) = gb_repository

View File

@ -78,14 +78,14 @@ impl HandlerInner {
};
let user = self.user_storage.get()?;
let project = self
.project_storage
.get_project(project_id)?
.context("project not found")?;
let gb_repo = gb_repository::Repository::open(
&self.local_data_dir,
project_id,
self.project_storage.clone(),
user.as_ref(),
)
.context("failed to open repository")?;
let gb_repo =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open repository")?;
gb_repo.push(user.as_ref()).context("failed to push")?;

View File

@ -36,19 +36,15 @@ impl Handler {
pub fn handle(&self, project_id: &str, now: &time::SystemTime) -> Result<Vec<events::Event>> {
let user = self.user_store.get()?;
let gb_repo = gb_repository::Repository::open(
&self.local_data_dir,
project_id,
self.project_store.clone(),
user.as_ref(),
)
.context("failed to open repository")?;
let project = match self.project_store.get_project(project_id)? {
None => return Ok(vec![]),
Some(project) => project,
};
let gb_repo =
gb_repository::Repository::open(&self.local_data_dir, &project, user.as_ref())
.context("failed to open repository")?;
let mut events = vec![];
if project