(
&mut self,
operation_lock: &super::locks::WorkingCopyOperationLockGuard,
working_copy: WorkingCopyId,
view: &str,
kind: OperationKind,
relation: Optio
| 546 | } |
| 547 | } |
| 548 | fn switch_view_journaled( |
| 549 | &mut self, |
| 550 | operation_lock: &super::locks::WorkingCopyOperationLockGuard, |
| 551 | working_copy: WorkingCopyId, |
| 552 | view: &str, |
| 553 | kind: OperationKind, |
| 554 | relation: Option<OperationRelation>, |
| 555 | actor: ActorRef, |
| 556 | ) -> Result<MaterializeResult, RepositoryError> { |
| 557 | self.validate_working_copy(working_copy)?; |
| 558 | let old_view_name = self.desired_view_name(working_copy)?; |
| 559 | let before_record = self.working_copy_record(working_copy)?; |
| 560 | let trace_switch = std::env::var_os("ATOMIC_TRACE_SWITCH").is_some(); |
| 561 | let phase_start = std::time::Instant::now(); |
| 562 | |
| 563 | // Resolve both views and validate both dependency closures before the |
| 564 | // switch publishes a pointer or mutates TREE-derived state. |
| 565 | let ( |
| 566 | old_files, |
| 567 | new_files, |
| 568 | new_file_materialization, |
| 569 | old_directories, |
| 570 | new_directories, |
| 571 | new_absent_files, |
| 572 | new_absent_directories, |
| 573 | new_visibility, |
| 574 | new_view_id, |
| 575 | old_state, |
| 576 | new_state, |
| 577 | ) = { |
| 578 | let txn = self |
| 579 | .pristine |
| 580 | .read_txn() |
| 581 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 582 | let old_view = txn |
| 583 | .get_view(&old_view_name) |
| 584 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 585 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 586 | name: old_view_name.clone(), |
| 587 | })?; |
| 588 | let new_view = txn |
| 589 | .get_view(view) |
| 590 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 591 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 592 | name: view.to_string(), |
| 593 | })?; |
| 594 | |
| 595 | let old_membership = view_membership(&txn, &old_view)?; |
| 596 | let new_membership = view_membership(&txn, &new_view)?; |
| 597 | // Legacy tolerance: members can predate the dependency index; |
| 598 | // degrade them to leaves instead of refusing the switch |
| 599 | // (dev #196/#206 parity — the unrecord-safety legacy fixtures). |
| 600 | let old_visibility = |
| 601 | GraphVisibilityClosure::try_from_membership_lenient(&txn, &old_membership) |
| 602 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 603 | let new_visibility = |
| 604 | GraphVisibilityClosure::try_from_membership_lenient(&txn, &new_membership) |
| 605 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
no test coverage detected