c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 1 | use matrix_sdk::{Room, event_cache::HistoryGapFillOutcome}; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 2 | use tokio::sync::watch; |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 3 | |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 4 | use super::{ |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 5 | executor::{JoinError, JoinHandle, spawn}, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 6 | timeline::SessionContext, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 7 | }; |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 8 | use crate::{ |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 9 | CommandOutput, Error, ErrorKind, HistoryContinuity, HistoryRepairBudget, HistoryRepairCommand, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 10 | HistoryRepairPhase, HistoryRepairPolicy, HistoryRepairReport, HistoryRepairStop, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 11 | HistoryRepairStrategy, RecentHistoryState, transport::Responder, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 12 | }; |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 13 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 14 | const MAX_GAP_PAGES: u32 = 4; |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 15 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 16 | struct Running { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 17 | task: JoinHandle<CompletionResult>, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 18 | cancel: watch::Sender<bool>, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 19 | responders: Vec<PendingResponder>, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 20 | recent: bool, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 21 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 22 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 23 | struct PendingResponder { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 24 | responder: Responder, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 25 | cancel_ack: bool, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 26 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 27 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 28 | pub(super) struct Completion { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 29 | pub(super) report: HistoryRepairReport, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 30 | pub(super) recent_state: Option<RecentHistoryState>, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 31 | pub(super) result: Result<CommandOutput, Error>, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 32 | responders: Vec<PendingResponder>, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 33 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 34 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 35 | impl Completion { |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 36 | pub(super) fn resolve( |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 37 | self, |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 38 | result: Result<CommandOutput, Error>, |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 39 | cancellation: Result<(), Error>, |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 40 | ) { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 41 | for responder in self.responders { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 42 | if responder.cancel_ack { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 43 | responder.responder.done(cancellation.clone()); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 44 | } else { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 45 | responder.responder.send(result.clone()); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 46 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 47 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 48 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 49 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 50 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 51 | struct CompletionResult { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 52 | report: HistoryRepairReport, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 53 | recent_state: Option<RecentHistoryState>, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 54 | result: Result<CommandOutput, Error>, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 55 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 56 | |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 57 | pub(super) struct RepairController { |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 58 | room: Room, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 59 | context: SessionContext, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 60 | running: Option<Running>, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 61 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 62 | |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 63 | impl RepairController { |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 64 | pub(super) fn new(room: Room, context: SessionContext) -> Self { |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 65 | Self { |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 66 | room, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 67 | context, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 68 | running: None, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 69 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 70 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 71 | |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 72 | pub(super) fn is_running(&self) -> bool { |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 73 | self.running.is_some() |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 74 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 75 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 76 | pub(super) async fn start_recent(&mut self) { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 77 | self.start_recent_with(HistoryRepairPolicy::default(), None, true, Vec::new()) |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 78 | .await; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 79 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 80 | |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 81 | pub(super) async fn execute(&mut self, command: HistoryRepairCommand, reply: Responder) { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 82 | match command { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 83 | HistoryRepairCommand::Cancel { .. } => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 84 | if let Some(running) = self.running.as_mut() { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 85 | running.responders.push(PendingResponder { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 86 | responder: reply, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 87 | cancel_ack: true, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 88 | }); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 89 | running.cancel.send_replace(true); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 90 | } else { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 91 | reply.done(Ok(())); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 92 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 93 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 94 | HistoryRepairCommand::Start { policy, budget, .. } => { |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 95 | if let Err(error) = validate_budget(&budget) { |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 96 | reply.done(Err(error)); |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 97 | return; |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 98 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 99 | let policy = policy.unwrap_or_default(); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 100 | self.start_recent_with(policy, Some(reply), true, Vec::new()) |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 101 | .await; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 102 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 103 | HistoryRepairCommand::StartRecent { .. } => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 104 | self.start_recent_with( |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 105 | HistoryRepairPolicy::default(), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 106 | Some(reply), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 107 | true, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 108 | Vec::new(), |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 109 | ) |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 110 | .await; |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 111 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 112 | HistoryRepairCommand::FillGap { gap_id, .. } => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 113 | self.start_gap_fill(gap_id, reply).await; |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 114 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 115 | HistoryRepairCommand::Continue { .. } => reply.done(Err(Error::new( |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 116 | ErrorKind::Invalid, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 117 | "continue requires a history gap ID, use FillGap", |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 118 | ))), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 119 | HistoryRepairCommand::GetPolicy => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 120 | reply.send( |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 121 | self.context |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 122 | .mentions |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 123 | .repair_policy() |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 124 | .await |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 125 | .map(CommandOutput::HistoryRepairPolicy), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 126 | ); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 127 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 128 | HistoryRepairCommand::SetPolicy(policy) => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 129 | reply.done(self.context.mentions.set_repair_policy(policy).await); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 130 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 131 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 132 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 133 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 134 | async fn start_recent_with( |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 135 | &mut self, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 136 | policy: HistoryRepairPolicy, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 137 | responder: Option<Responder>, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 138 | publish_recent: bool, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 139 | mut responders: Vec<PendingResponder>, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 140 | ) { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 141 | if let Some(running) = &mut self.running { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 142 | if let Some(responder) = responder { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 143 | if running.recent { |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 144 | running.responders.push(PendingResponder { |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 145 | responder, |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 146 | cancel_ack: false, |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 147 | }); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 148 | } else { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 149 | responder.done(Err(room_busy())); |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 150 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 151 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 152 | return; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 153 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 154 | if let Some(responder) = responder { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 155 | responders.push(PendingResponder { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 156 | responder, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 157 | cancel_ack: false, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 158 | }); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 159 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 160 | if publish_recent |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 161 | && self |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 162 | .context |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 163 | .events |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 164 | .send(crate::Event::RecentHistoryChanged { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 165 | room_id: self.room.room_id().to_owned(), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 166 | state: RecentHistoryState::Loading, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 167 | }) |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 168 | .await |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 169 | .is_err() |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 170 | { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 171 | for responder in responders { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 172 | responder.responder.done(Err(Error::interrupted())); |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 173 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 174 | return; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 175 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 176 | let (cancel, receiver) = watch::channel(false); |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 177 | let room = self.room.clone(); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 178 | let room_id = self.room.room_id().to_owned(); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 179 | let task = spawn(async move { load_recent(room, room_id, policy, receiver).await }); |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 180 | self.running = Some(Running { |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 181 | task, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 182 | cancel, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 183 | responders, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 184 | recent: true, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 185 | }); |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 186 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 187 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 188 | async fn start_gap_fill(&mut self, gap_id: ruma::OwnedTransactionId, responder: Responder) { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 189 | if self.is_running() { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 190 | responder.done(Err(room_busy())); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 191 | return; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 192 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 193 | let room = self.room.clone(); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 194 | let room_id = self.room.room_id().to_owned(); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 195 | let mut progress = report(room_id.clone(), HistoryRepairPolicy::default()); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 196 | progress.gap_id = Some(gap_id.clone()); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 197 | progress.strategy = HistoryRepairStrategy::Bridge; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 198 | progress.phase = HistoryRepairPhase::Bridging; |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 199 | if self |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 200 | .context |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 201 | .events |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 202 | .send(crate::Event::HistoryRepairChanged(progress)) |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 203 | .await |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 204 | .is_err() |
9eabb6b7587d | atagen | 2026-10-25 07:08 UTC | 205 | { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 206 | responder.done(Err(Error::interrupted())); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 207 | return; |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 208 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 209 | let (cancel, receiver) = watch::channel(false); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 210 | let task = spawn(async move { fill_gap(room, room_id, gap_id, receiver).await }); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 211 | self.running = Some(Running { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 212 | task, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 213 | cancel, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 214 | responders: vec![PendingResponder { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 215 | responder, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 216 | cancel_ack: false, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 217 | }], |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 218 | recent: false, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 219 | }); |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 220 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 221 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 222 | pub(super) async fn next_completion(&mut self) -> Option<Completion> { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 223 | let running = self.running.as_mut()?; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 224 | let result = (&mut running.task).await; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 225 | Some(self.finish_task(result)) |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 226 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 227 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 228 | pub(super) async fn shutdown(&mut self) -> Option<Completion> { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 229 | let running = self.running.as_mut()?; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 230 | running.cancel.send_replace(true); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 231 | let result = (&mut running.task).await; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 232 | Some(self.finish_task(result)) |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 233 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 234 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 235 | fn finish_task(&mut self, result: Result<CompletionResult, JoinError>) -> Completion { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 236 | let running = self.running.take().expect("repair task exists"); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 237 | let result = match result { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 238 | Ok(result) => result, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 239 | Err(_) => CompletionResult { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 240 | report: failed_report( |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 241 | self.room.room_id().to_owned(), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 242 | HistoryRepairPolicy::default(), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 243 | Error::interrupted(), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 244 | ), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 245 | recent_state: running.recent.then(|| { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 246 | RecentHistoryState::Failed( |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 247 | "recent history operation was interrupted".to_owned(), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 248 | ) |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 249 | }), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 250 | result: Err(Error::interrupted()), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 251 | }, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 252 | }; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 253 | Completion { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 254 | report: result.report, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 255 | recent_state: result.recent_state, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 256 | result: result.result, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 257 | responders: running.responders, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 258 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 259 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 260 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 261 | |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 262 | fn validate_budget(budget: &HistoryRepairBudget) -> Result<(), Error> { |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 263 | if !(1..=100).contains(&budget.max_pages) |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 264 | || !(50..=10_000).contains(&budget.max_events) |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 265 | || !(1..=60_000).contains(&budget.max_duration_ms) |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 266 | { |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 267 | return Err(Error::new( |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 268 | ErrorKind::Invalid, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 269 | "repair budget requires 1 to 100 pages, 50 to 10000 events, and 1 to 60000 milliseconds", |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 270 | )); |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 271 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 272 | Ok(()) |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 273 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 274 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 275 | async fn load_recent( |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 276 | room: Room, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 277 | room_id: ruma::OwnedRoomId, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 278 | policy: HistoryRepairPolicy, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 279 | mut cancel: watch::Receiver<bool>, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 280 | ) -> CompletionResult { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 281 | let base = report(room_id.clone(), policy); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 282 | let outcome = tokio::select! { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 283 | biased; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 284 | _ = cancel.changed() => Err(Error::interrupted()), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 285 | result = async { |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 286 | let (cache, _handles) = room.event_cache().await.map_err(cache_error)?; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 287 | cache.load_recent_history().await.map_err(cache_error) |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 288 | } => result, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 289 | }; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 290 | match outcome { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 291 | Ok(outcome) => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 292 | let mut report = base; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 293 | report.pages = outcome.pages; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 294 | report.events = outcome.events.min(u32::MAX as usize) as u32; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 295 | report.recent_available = true; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 296 | report.phase = HistoryRepairPhase::Ready; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 297 | match outcome.gap.map(|gap| gap.status) { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 298 | None => report.continuity = HistoryContinuity::AccessibleStart, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 299 | Some(matrix_sdk::event_cache::HistoryGapStatus::Joined) => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 300 | report.continuity = HistoryContinuity::Verified |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 301 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 302 | Some(matrix_sdk::event_cache::HistoryGapStatus::Unavailable) => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 303 | report.continuity = HistoryContinuity::AccessibleStart; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 304 | report.stop = Some(HistoryRepairStop::HistoryUnavailable); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 305 | report.phase = HistoryRepairPhase::Paused; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 306 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 307 | Some(matrix_sdk::event_cache::HistoryGapStatus::Paused) => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 308 | report.stop = Some(HistoryRepairStop::CursorStalled); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 309 | report.phase = HistoryRepairPhase::Paused; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 310 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 311 | Some(matrix_sdk::event_cache::HistoryGapStatus::Failed { message }) => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 312 | let error = Error::new(ErrorKind::Network, message.clone()); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 313 | report.failure = Some(error.clone()); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 314 | report.phase = HistoryRepairPhase::Paused; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 315 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 316 | Some(matrix_sdk::event_cache::HistoryGapStatus::Idle) => {} |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 317 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 318 | CompletionResult { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 319 | report: report.clone(), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 320 | recent_state: Some(RecentHistoryState::Loaded), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 321 | result: Ok(CommandOutput::HistoryRepair(report)), |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 322 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 323 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 324 | Err(error) => CompletionResult { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 325 | report: failed_report(room_id, base.requested_policy, error.clone()), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 326 | recent_state: Some(RecentHistoryState::Failed(error.message.clone())), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 327 | result: Err(error), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 328 | }, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 329 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 330 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 331 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 332 | async fn fill_gap( |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 333 | room: Room, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 334 | room_id: ruma::OwnedRoomId, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 335 | gap_id: ruma::OwnedTransactionId, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 336 | mut cancel: watch::Receiver<bool>, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 337 | ) -> CompletionResult { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 338 | let mut report = report(room_id, HistoryRepairPolicy::default()); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 339 | report.gap_id = Some(gap_id.clone()); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 340 | report.strategy = HistoryRepairStrategy::Bridge; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 341 | let outcome = async { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 342 | let (cache, _handles) = room.event_cache().await.map_err(cache_error)?; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 343 | let mut last_gap = None; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 344 | for _ in 0..MAX_GAP_PAGES { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 345 | let next = tokio::select! { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 346 | biased; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 347 | _ = cancel.changed() => return Err(Error::interrupted()), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 348 | result = cache.fill_history_gap_once(gap_id.clone()) => result.map_err(cache_error)?, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 349 | }; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 350 | match next { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 351 | HistoryGapFillOutcome::NotFound => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 352 | return Err(Error::new(ErrorKind::EventNotFound, "history gap was not found")); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 353 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 354 | HistoryGapFillOutcome::Busy => return Err(room_busy()), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 355 | HistoryGapFillOutcome::Updated { gap, events } => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 356 | report.pages += 1; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 357 | report.events = report.events.saturating_add(events.min(u32::MAX as usize) as u32); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 358 | match gap.status.clone() { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 359 | matrix_sdk::event_cache::HistoryGapStatus::Joined => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 360 | report.continuity = HistoryContinuity::Verified; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 361 | last_gap = Some(gap); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 362 | break; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 363 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 364 | matrix_sdk::event_cache::HistoryGapStatus::Unavailable => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 365 | report.continuity = HistoryContinuity::AccessibleStart; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 366 | report.stop = Some(HistoryRepairStop::HistoryUnavailable); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 367 | last_gap = Some(gap); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 368 | break; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 369 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 370 | matrix_sdk::event_cache::HistoryGapStatus::Paused => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 371 | report.stop = Some(HistoryRepairStop::CursorStalled); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 372 | last_gap = Some(gap); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 373 | break; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 374 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 375 | matrix_sdk::event_cache::HistoryGapStatus::Failed { message } => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 376 | return Err(Error::new(ErrorKind::Network, message)); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 377 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 378 | matrix_sdk::event_cache::HistoryGapStatus::Idle => last_gap = Some(gap), |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 379 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 380 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 381 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 382 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 383 | if report.pages == MAX_GAP_PAGES |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 384 | && report.continuity == HistoryContinuity::Unresolved |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 385 | && report.stop.is_none() |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 386 | { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 387 | report.stop = Some(HistoryRepairStop::Budget); |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 388 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 389 | Ok::<_, Error>(last_gap) |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 390 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 391 | .await; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 392 | let command_result = match outcome { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 393 | Ok(_) => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 394 | report.recent_available = true; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 395 | report.phase = if report.stop.is_some() { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 396 | HistoryRepairPhase::Paused |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 397 | } else { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 398 | HistoryRepairPhase::Ready |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 399 | }; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 400 | Ok(CommandOutput::Done) |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 401 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 402 | Err(error) => { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 403 | report.failure = Some(error.clone()); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 404 | report.phase = HistoryRepairPhase::Paused; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 405 | Err(error) |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 406 | } |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 407 | }; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 408 | CompletionResult { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 409 | report, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 410 | recent_state: None, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 411 | result: command_result, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 412 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 413 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 414 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 415 | fn report(room_id: ruma::OwnedRoomId, policy: HistoryRepairPolicy) -> HistoryRepairReport { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 416 | HistoryRepairReport { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 417 | room_id, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 418 | gap_id: None, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 419 | requested_policy: policy, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 420 | strategy: HistoryRepairStrategy::Recent, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 421 | coverage_duration_ms: None, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 422 | threshold_evaluated: false, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 423 | pages: 0, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 424 | events: 0, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 425 | phase: HistoryRepairPhase::FetchingRecent, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 426 | continuity: HistoryContinuity::Unresolved, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 427 | recent_available: false, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 428 | stop: None, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 429 | failure: None, |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 430 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 431 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 432 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 433 | fn failed_report( |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 434 | room_id: ruma::OwnedRoomId, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 435 | policy: HistoryRepairPolicy, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 436 | error: Error, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 437 | ) -> HistoryRepairReport { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 438 | let mut report = report(room_id, policy); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 439 | report.phase = HistoryRepairPhase::Paused; |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 440 | report.failure = Some(error); |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 441 | report |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 442 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 443 | |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 444 | fn cache_error(source: matrix_sdk::event_cache::EventCacheError) -> Error { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 445 | Error::with_source(ErrorKind::Store, "room history operation failed", source) |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 446 | } |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 447 | |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 448 | fn room_busy() -> Error { |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 449 | Error::new( |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 450 | ErrorKind::RoomBusy, |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 451 | "room history operation is already running", |
c9f0fd0ee1cc | atagen | 2026-10-25 06:16 UTC | 452 | ) |
80381e06a573 | atagen | 2026-10-25 03:02 UTC | 453 | } |