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,
)
| 157 | /// - `TrunkNotFound` - The trunk doesn't exist |
| 158 | /// - `InvalidTrunkState` - The trunk is already deleted |
| 159 | fn apply_delete<T: MutCrdtTxnT>( |
| 160 | txn: &mut T, |
| 161 | context: &mut ApplyContext, |
| 162 | trunk_id: TrunkId, |
| 163 | ) -> ApplyResult<()> { |
| 164 | // Verify trunk exists |
| 165 | let trunk = txn |
| 166 | .get_trunk(trunk_id) |
| 167 | .map_err(|e| storage_err(e, "getting trunk"))? |
| 168 | .ok_or_else(|| ApplyError::trunk_not_found(trunk_id))?; |
| 169 | |
| 170 | // Check current state |
| 171 | if trunk.state().is_deleted() { |
| 172 | if context.options().allow_duplicate_ids() { |
| 173 | context.record_skipped(); |
| 174 | return Ok(()); |
| 175 | } |
| 176 | return Err(ApplyError::invalid_trunk_state( |
| 177 | trunk_id, "deleted", "delete", |
| 178 | )); |
| 179 | } |
| 180 | |
| 181 | // Update state to deleted |
| 182 | txn.update_trunk_state(trunk_id, TrunkState::Deleted) |
| 183 | .map_err(|e| storage_err(e, "updating trunk state"))?; |
| 184 | |
| 185 | context.record_trunk_deleted(); |
| 186 | Ok(()) |
| 187 | } |
| 188 | |
| 189 | // Move Operation |
| 190 |
no test coverage detected