MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / checkpoint_shadow_switch

Function checkpoint_shadow_switch

atomic-cli/src/commands/view/switch.rs:107–149  ·  view source on GitHub ↗
(
    shadow_sync: crate::commands::git::shadow::ShadowSwitchSync,
    repo_root: &std::path::Path,
    view: &str,
)

Source from the content-addressed store, hash-verified

105}
106
107fn checkpoint_shadow_switch(
108 shadow_sync: crate::commands::git::shadow::ShadowSwitchSync,
109 repo_root: &std::path::Path,
110 view: &str,
111) -> CliResult<()> {
112 let shadow_was_synchronized = shadow_sync.is_synchronized();
113 // A native (unenrolled) colocated repository must neither fail its view
114 // switch on Git observation errors nor bootstrap the first shim
115 // checkpoint: `.git` beside `.atomic` is not shim consent. Only an
116 // enrolled workspace refreshes; import anchors explicitly.
117 if !shadow_was_synchronized
118 && !crate::commands::git::shadow::shim_workspace_enrolled(repo_root)?
119 {
120 return Ok(());
121 }
122 let checkpoint = match crate::commands::git::shim::refresh_checkpoint_if_aligned(repo_root) {
123 Ok(outcome) => outcome,
124 Err(error) => {
125 return match shadow_sync.rollback(repo_root) {
126 Ok(()) => Err(error),
127 Err(rollback_error) => Err(CliError::GitError {
128 message: format!("{error}; {rollback_error}"),
129 }),
130 };
131 }
132 };
133 if shadow_was_synchronized
134 && checkpoint != crate::commands::git::shim::CheckpointRefresh::Refreshed
135 {
136 let error = CliError::GitError {
137 message: format!(
138 "Git shadow synchronization for view '{view}' completed, but the shim verifier did not refresh its checkpoint ({checkpoint:?}); run `atomic git shim verify` for details"
139 ),
140 };
141 return match shadow_sync.rollback(repo_root) {
142 Ok(()) => Err(error),
143 Err(rollback_error) => Err(CliError::GitError {
144 message: format!("{error}; {rollback_error}"),
145 }),
146 };
147 }
148 Ok(())
149}
150
151/// Finish the existing Git boundary after a successful service-owned native
152/// switch. The service has released its workspace lease and database handle.

Callers 3

finish_service_switchFunction · 0.85
runMethod · 0.85

Calls 4

shim_workspace_enrolledFunction · 0.85
is_synchronizedMethod · 0.80
rollbackMethod · 0.80