init flushing

This commit is contained in:
Nikita Galaiko 2023-04-14 15:38:48 +02:00
parent 198f5b55df
commit 0b3ad99a7c
2 changed files with 40 additions and 3 deletions

View File

@ -5,7 +5,11 @@ use uuid::Uuid;
use crate::{projects, sessions};
use super::{project_repository, reader, session};
use super::{
project_repository,
reader::{self, Reader},
session,
};
pub struct Repository {
pub(crate) project_id: String,
@ -121,6 +125,39 @@ impl Repository {
}
}
pub fn flush(&self) -> Result<Option<sessions::Session>> {
let current_session = self
.get_current_session()
.context("failed to get current session")?;
if current_session.is_none() {
return Ok(None);
}
let current_session = current_session.unwrap();
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)
.context("failed to open project repository")?;
let project_wd_reader = project_repository.get_wd_reader();
let current_session_writer = self
.get_session_writer(&current_session)
.context("failed to get session writer")?;
// read from wd
// write to session
// create commit
Err(anyhow!("not implemented"))
}
pub fn get_session_reader(&self, session: sessions::Session) -> Result<session::SessionReader> {
session::SessionReader::open(&self, session)
}

View File

@ -2,10 +2,10 @@ use std::collections::HashMap;
use anyhow::{anyhow, Context, Result};
use crate::{deltas, pty, sessions};
use crate::{deltas, projects, pty, sessions};
use super::{
gb_repository,
gb_repository, project_repository,
reader::{self, Reader},
writer::{self, Writer},
};