mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-03 15:06:01 +03:00
fetch project in background
This commit is contained in:
parent
21ec8d9f14
commit
1e3d0244db
@ -373,7 +373,11 @@ impl<'repository> Repository<'repository> {
|
|||||||
"failed to push: {}",
|
"failed to push: {}",
|
||||||
String::from_utf8(output.stderr).unwrap()
|
String::from_utf8(output.stderr).unwrap()
|
||||||
)
|
)
|
||||||
})
|
})?;
|
||||||
|
|
||||||
|
log::info!("{}: pushed {} to {}", self.project.id, head, upstream);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fetch(&self) -> Result<()> {
|
pub fn fetch(&self) -> Result<()> {
|
||||||
@ -389,7 +393,11 @@ impl<'repository> Repository<'repository> {
|
|||||||
"failed to fetch: {}",
|
"failed to fetch: {}",
|
||||||
String::from_utf8(output.stderr).unwrap()
|
String::from_utf8(output.stderr).unwrap()
|
||||||
)
|
)
|
||||||
})
|
})?;
|
||||||
|
|
||||||
|
log::info!("{}: fetched", self.project.id);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn git_commit(&self, message: &str, push: bool) -> Result<()> {
|
pub fn git_commit(&self, message: &str, push: bool) -> Result<()> {
|
||||||
|
@ -2,7 +2,7 @@ use std::{path, time};
|
|||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
|
|
||||||
use crate::{gb_repository, projects, users};
|
use crate::{gb_repository, project_repository, projects, users};
|
||||||
|
|
||||||
use super::events;
|
use super::events;
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ impl Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle(&self) -> Result<Vec<events::Event>> {
|
pub fn handle(&self) -> Result<Vec<events::Event>> {
|
||||||
let gb_rep = gb_repository::Repository::open(
|
let gb_repo = gb_repository::Repository::open(
|
||||||
self.local_data_dir.clone(),
|
self.local_data_dir.clone(),
|
||||||
self.project_id.clone(),
|
self.project_id.clone(),
|
||||||
self.project_storage.clone(),
|
self.project_storage.clone(),
|
||||||
@ -38,11 +38,33 @@ impl Handler {
|
|||||||
)
|
)
|
||||||
.context("failed to open repository")?;
|
.context("failed to open repository")?;
|
||||||
|
|
||||||
let sessions_before_fetch = gb_rep
|
let sessions_before_fetch = gb_repo
|
||||||
.get_sessions_iterator()?
|
.get_sessions_iterator()?
|
||||||
.filter_map(|s| s.ok())
|
.filter_map(|s| s.ok())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
if !gb_rep.fetch().context("failed to fetch")? {
|
|
||||||
|
let mut fetched = false;
|
||||||
|
if let Err(err) = gb_repo.fetch() {
|
||||||
|
log::error!("failed to fetch: {}", err);
|
||||||
|
} else {
|
||||||
|
fetched = true
|
||||||
|
};
|
||||||
|
|
||||||
|
let project = self
|
||||||
|
.project_storage
|
||||||
|
.get_project(&self.project_id)
|
||||||
|
.context("failed to get project")?
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("project not found"))?;
|
||||||
|
let project_repository = project_repository::Repository::open(&project)
|
||||||
|
.context("failed to open project repository")?;
|
||||||
|
|
||||||
|
if let Err(err) = project_repository.fetch() {
|
||||||
|
log::error!("failed to fetch: {}", err);
|
||||||
|
} else {
|
||||||
|
fetched = true
|
||||||
|
};
|
||||||
|
|
||||||
|
if !fetched {
|
||||||
return Ok(vec![]);
|
return Ok(vec![]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +81,7 @@ impl Handler {
|
|||||||
})
|
})
|
||||||
.context("failed to update project")?;
|
.context("failed to update project")?;
|
||||||
|
|
||||||
let sessions_after_fetch = gb_rep
|
let sessions_after_fetch = gb_repo
|
||||||
.get_sessions_iterator()?
|
.get_sessions_iterator()?
|
||||||
.filter_map(|s| s.ok())
|
.filter_map(|s| s.ok())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
Loading…
Reference in New Issue
Block a user