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

Function restore

atomic-cli/src/commands/rpc.rs:3719–3745  ·  view source on GitHub ↗

`atomic restore` over Restore. The non-dry-run forms route; every dry-run form routes through the PreviewRestore arm the command dispatches next — the listing form (no paths, or more than one) via `restore_preview`, the single-file pristine-bytes dump via `restore_single_dry_run` (the wire's content arm). The whole-copy refusal surfaces with the daemon's message.

(args: &super::restore::Restore)

Source from the content-addressed store, hash-verified

3717/// `restore_single_dry_run` (the wire's content arm). The whole-copy
3718/// refusal surfaces with the daemon's message.
3719pub fn restore(args: &super::restore::Restore) -> CliResult<bool> {
3720 if args.dry_run {
3721 return Ok(false);
3722 }
3723 let Some(session) = Service::open()? else {
3724 return Ok(false);
3725 };
3726 let request = pb::RestoreRequest {
3727 repository: Some(session.reference.clone()),
3728 meta: None,
3729 paths: args.files.clone(),
3730 force: args.force,
3731 };
3732 let response = session.restore(request)?;
3733
3734 if response.restored.is_empty() {
3735 println!("Nothing to restore - working copy is clean");
3736 return Ok(true);
3737 }
3738 println!("Restoring working copy...");
3739 for path in &response.restored {
3740 println!(" Restored: {path}");
3741 }
3742 println!();
3743 print_success(&format!("Restored {} file(s)", response.restored.len()));
3744 Ok(true)
3745}
3746
3747// ---------------------------------------------------------------------------
3748// stash (RepositoryMutationService)

Callers 2

runMethod · 0.85
test_line_ops_restoreFunction · 0.85

Calls 5

openFunction · 0.85
print_successFunction · 0.85
cloneMethod · 0.45
restoreMethod · 0.45
is_emptyMethod · 0.45

Tested by 1

test_line_ops_restoreFunction · 0.68