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

Function restore_single_dry_run

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

`atomic restore --dry-run ` (the single-file form) over PreviewRestore's content arm — the handler reads the file's pristine bytes with the same domain call the local body makes; the CLI dumps them to stdout byte-for-byte (no extra output). An Added file previews the untrack instead (the local listing branch), and no pristine content is the local FileNotFound error.

(path: &str)

Source from the content-addressed store, hash-verified

4841/// the untrack instead (the local listing branch), and no pristine
4842/// content is the local FileNotFound error.
4843pub fn restore_single_dry_run(path: &str) -> CliResult<bool> {
4844 let Some(session) = Service::open()? else {
4845 return Ok(false);
4846 };
4847 let request = pb::PreviewRestoreRequest {
4848 repository: Some(session.reference.clone()),
4849 paths: vec![path.to_string()],
4850 force: false,
4851 content_path: Some(path.to_string()),
4852 };
4853 let response = session.preview_restore(request)?;
4854 if !response.untracked.is_empty() {
4855 // The single Added file: the local listing branch's lines.
4856 render_restore_preview(&response, true);
4857 return Ok(true);
4858 }
4859 match response.pristine_content {
4860 Some(bytes) => {
4861 use std::io::Write;
4862 std::io::stdout()
4863 .write_all(&bytes)
4864 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to write: {}", e)))?;
4865 Ok(true)
4866 }
4867 None => Err(CliError::FileNotFound {
4868 path: PathBuf::from(path),
4869 }),
4870 }
4871}
4872
4873/// `atomic insert preview` over PreviewMutation (InsertPreview).
4874pub fn insert_preview(

Callers 1

runMethod · 0.85

Calls 6

render_restore_previewFunction · 0.85
stdoutFunction · 0.85
openFunction · 0.50
cloneMethod · 0.45
preview_restoreMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected