Applies a Delete operation to mark a file as deleted. # Behavior 1. Verifies the trunk exists 2. Verifies the trunk is not already deleted 3. Updates the trunk's state to Deleted Note: The trunk entry remains in the database (tombstone). Associated branches and leaves are not automatically deleted. # Errors - `TrunkNotFound` - The trunk doesn't exist - `InvalidTrunkState` - The trunk is alrea
(
txn: &mut T,
context: &mut ApplyContext,
trunk_id: TrunkId,
)
| 164 | /// - `TrunkNotFound` - The trunk doesn't exist |
| 165 | /// - `InvalidTrunkState` - The trunk is already deleted |
| 166 | fn apply_delete<T: MutCrdtTxnT>( |
| 167 | txn: &mut T, |
| 168 | context: &mut ApplyContext, |
| 169 | trunk_id: TrunkId, |
| 170 | ) -> ApplyResult<()> { |
| 171 | // Verify trunk exists |
| 172 | let trunk = txn |
| 173 | .get_trunk(trunk_id) |
| 174 | .map_err(|e| storage_err(e, "getting trunk"))? |
| 175 | .ok_or_else(|| ApplyError::trunk_not_found(trunk_id))?; |
| 176 | |
| 177 | // Check current state |
| 178 | if trunk.state().is_deleted() { |
| 179 | if context.options().allow_duplicate_ids() { |
| 180 | context.record_skipped(); |
| 181 | return Ok(()); |
| 182 | } |
| 183 | return Err(ApplyError::invalid_trunk_state( |
| 184 | trunk_id, "deleted", "delete", |
| 185 | )); |
| 186 | } |
| 187 | |
| 188 | // Update state to deleted |
| 189 | txn.update_trunk_state(trunk_id, TrunkState::Deleted) |
| 190 | .map_err(|e| storage_err(e, "updating trunk state"))?; |
| 191 | |
| 192 | context.record_trunk_deleted(); |
| 193 | Ok(()) |
| 194 | } |
| 195 | |
| 196 | // Move Operation |
| 197 |
no test coverage detected