remove unused flush event

This commit is contained in:
Kiril Videlov 2024-05-12 02:22:05 +02:00
parent 18cf10a143
commit d51761a654
2 changed files with 2 additions and 68 deletions

View File

@ -8,7 +8,6 @@ use gitbutler_core::{projects::ProjectId, sessions};
#[derive(Debug)]
pub(super) enum InternalEvent {
// From public action API
Flush(ProjectId, sessions::Session),
CalculateVirtualBranches(ProjectId),
// From file monitor
@ -22,7 +21,6 @@ pub(super) enum InternalEvent {
#[derive(Debug, PartialEq, Clone)]
#[allow(missing_docs)]
pub enum Action {
Flush(ProjectId, sessions::Session),
CalculateVirtualBranches(ProjectId),
}
@ -30,9 +28,7 @@ impl Action {
/// Return the action's associated project id.
pub fn project_id(&self) -> ProjectId {
match self {
Action::Flush(project_id, _) | Action::CalculateVirtualBranches(project_id) => {
*project_id
}
Action::CalculateVirtualBranches(project_id) => *project_id,
}
}
}
@ -40,7 +36,6 @@ impl Action {
impl From<Action> for InternalEvent {
fn from(value: Action) -> Self {
match value {
Action::Flush(a, b) => InternalEvent::Flush(a, b),
Action::CalculateVirtualBranches(v) => InternalEvent::CalculateVirtualBranches(v),
}
}
@ -49,9 +44,6 @@ impl From<Action> for InternalEvent {
impl Display for InternalEvent {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
InternalEvent::Flush(project_id, session) => {
write!(f, "Flush({}, {})", project_id, session.id)
}
InternalEvent::GitFilesChange(project_id, paths) => {
write!(
f,

View File

@ -12,8 +12,7 @@ use gitbutler_core::projects::ProjectId;
use gitbutler_core::sessions::SessionId;
use gitbutler_core::virtual_branches::VirtualBranches;
use gitbutler_core::{
assets, deltas, gb_repository, git, project_repository, projects, reader, sessions, users,
virtual_branches,
assets, deltas, git, project_repository, projects, reader, sessions, users, virtual_branches,
};
use tracing::instrument;
@ -80,11 +79,6 @@ impl Handler {
.await
.context("failed to handle git file change event"),
events::InternalEvent::Flush(project_id, session) => self
.flush_session(project_id, &session)
.await
.context("failed to handle flush session event"),
events::InternalEvent::CalculateVirtualBranches(project_id) => self
.calculate_virtual_branches(project_id)
.await
@ -113,34 +107,6 @@ impl Handler {
})
}
async fn flush_session(
&self,
project_id: ProjectId,
session: &sessions::Session,
) -> Result<()> {
let project = self
.projects
.get(&project_id)
.context("failed to get project")?;
let user = self.users.get_user()?;
let project_repository =
project_repository::Repository::open(&project).context("failed to open repository")?;
let gb_repo = gb_repository::Repository::open(
&self.local_data_dir,
&project_repository,
user.as_ref(),
)
.context("failed to open repository")?;
let session = gb_repo
.flush_session(&project_repository, session, user.as_ref())
.context(format!("failed to flush session {}", session.id))?;
self.index_session(project_id, session)?;
Ok(())
}
#[instrument(skip(self, project_id))]
async fn calculate_virtual_branches(&self, project_id: ProjectId) -> Result<()> {
match self
@ -226,30 +192,6 @@ impl Handler {
"logs/HEAD" => {
self.emit_app_event(Change::GitActivity(project.id))?;
}
"GB_FLUSH" => {
let user = self.users.get_user()?;
let project_repository = open_projects_repository()?;
let gb_repo = gb_repository::Repository::open(
&self.local_data_dir,
&project_repository,
user.as_ref(),
)
.context("failed to open repository")?;
let gb_flush_path = project.path.join(".git/GB_FLUSH");
if gb_flush_path.exists() {
if let Err(err) = std::fs::remove_file(&gb_flush_path) {
tracing::error!(%project_id, path = %gb_flush_path.display(), "GB_FLUSH file delete error: {err}");
}
if let Some(current_session) = gb_repo
.get_current_session()
.context("failed to get current session")?
{
self.flush_session(project.id, &current_session).await?;
}
}
}
"HEAD" => {
let project_repository = open_projects_repository()?;
let head_ref = project_repository