feat: freeze Host Journal context across compaction
This commit is contained in:
@@ -71,11 +71,30 @@ impl SubjektivStore {
|
||||
&self,
|
||||
host: &JournalHostContext,
|
||||
previous_session: Option<&str>,
|
||||
) -> JournalResult<JournalStartupSnapshot> {
|
||||
self.context_snapshot(host, previous_session, false)
|
||||
}
|
||||
|
||||
pub fn journal_compaction_snapshot(
|
||||
&self,
|
||||
host: &JournalHostContext,
|
||||
) -> JournalResult<JournalStartupSnapshot> {
|
||||
let session = host.attribution.as_ref().ok_or_else(|| {
|
||||
JournalError::PermissionDenied("compaction requires a Host-bound body Session".into())
|
||||
})?;
|
||||
self.context_snapshot(host, Some(&session.session_id), true)
|
||||
}
|
||||
|
||||
fn context_snapshot(
|
||||
&self,
|
||||
host: &JournalHostContext,
|
||||
preferred_session: Option<&str>,
|
||||
require_current_writer: bool,
|
||||
) -> JournalResult<JournalStartupSnapshot> {
|
||||
self.database.try_transaction(|tx| {
|
||||
super::store::check_host(self, tx, host, false)?;
|
||||
super::store::check_host(self, tx, host, require_current_writer)?;
|
||||
let mut ids = Vec::new();
|
||||
if let Some(session) = previous_session {
|
||||
if let Some(session) = preferred_session {
|
||||
let previous: Option<(String, String)> = tx.query_row(
|
||||
"SELECT id,subject_id FROM journals WHERE source_session_id=?1",
|
||||
[session], |r| Ok((r.get(0)?, r.get(1)?)),
|
||||
|
||||
@@ -21,6 +21,12 @@ pub enum JournalRecordingReason {
|
||||
WorkerRestored,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct JournalCompactionRequest {
|
||||
pub session_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct JournalRecordingRequest {
|
||||
|
||||
Reference in New Issue
Block a user