Apply a TrunkOp (file-level operation).
(
txn: &mut T,
trunk_id: TrunkId,
path: &str,
trunk_op: &TrunkOp,
stats: &mut ApplyFileOpsStats,
created_inodes: &HashMap<String, Inode>,
)
| 634 | |
| 635 | /// Apply a TrunkOp (file-level operation). |
| 636 | fn apply_trunk_op<T: MutTxnT>( |
| 637 | txn: &mut T, |
| 638 | trunk_id: TrunkId, |
| 639 | path: &str, |
| 640 | trunk_op: &TrunkOp, |
| 641 | stats: &mut ApplyFileOpsStats, |
| 642 | created_inodes: &HashMap<String, Inode>, |
| 643 | ) -> PristineResult<()> { |
| 644 | match trunk_op { |
| 645 | TrunkOp::Create { encoding, .. } => { |
| 646 | let inode = resolve_created_inode(txn, path, created_inodes)?; |
| 647 | |
| 648 | // Create the serialized trunk record |
| 649 | let serialized = SerializedTrunk { |
| 650 | inode, |
| 651 | state: TrunkState::Alive, |
| 652 | encoding: encoding_to_u8(encoding.as_ref()), |
| 653 | path: path.to_string(), |
| 654 | }; |
| 655 | |
| 656 | // Store in CRDT tables |
| 657 | put_trunk(txn, trunk_id, &serialized)?; |
| 658 | stats.trunks_created += 1; |
| 659 | } |
| 660 | |
| 661 | TrunkOp::Delete { .. } => { |
| 662 | // Mark trunk as deleted (don't remove - CRDT semantics) |
| 663 | update_trunk_state(txn, trunk_id, TrunkState::Deleted)?; |
| 664 | stats.trunks_deleted += 1; |
| 665 | } |
| 666 | |
| 667 | TrunkOp::Move { new_path, .. } => { |
| 668 | // Update trunk path |
| 669 | update_trunk_path(txn, trunk_id, new_path)?; |
| 670 | stats.trunks_moved += 1; |
| 671 | } |
| 672 | |
| 673 | TrunkOp::Undelete { .. } => { |
| 674 | // Restore trunk to alive state |
| 675 | update_trunk_state(txn, trunk_id, TrunkState::Alive)?; |
| 676 | // Count as created for stats purposes |
| 677 | stats.trunks_created += 1; |
| 678 | } |
| 679 | |
| 680 | // GraphOp::SetAttr owns persistence; FileOps carries the semantic fact. |
| 681 | TrunkOp::SetMode { .. } | TrunkOp::SetKind { .. } => {} |
| 682 | TrunkOp::ProjectedSpanEdit { .. } => { |
| 683 | return Err(PristineError::Inconsistent { |
| 684 | message: "projected span edit requires span-aware validation and application" |
| 685 | .into(), |
| 686 | }) |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | Ok(()) |
| 691 | } |
| 692 | |
| 693 | /// Apply a BranchOp (line-level operation) with optional graph position linkage. |
no test coverage detected