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

Function restore_single_dry_run

atomic-cli/src/commands/rpc.rs:4803–4831  ·  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

4801/// the untrack instead (the local listing branch), and no pristine
4802/// content is the local FileNotFound error.
4803pub fn restore_single_dry_run(path: &str) -> CliResult<bool> {
4804 let Some(session) = Service::open()? else {
4805 return Ok(false);
4806 };
4807 let request = pb::PreviewRestoreRequest {
4808 repository: Some(session.reference.clone()),
4809 paths: vec![path.to_string()],
4810 force: false,
4811 content_path: Some(path.to_string()),
4812 };
4813 let response = session.preview_restore(request)?;
4814 if !response.untracked.is_empty() {
4815 // The single Added file: the local listing branch's lines.
4816 render_restore_preview(&response, true);
4817 return Ok(true);
4818 }
4819 match response.pristine_content {
4820 Some(bytes) => {
4821 use std::io::Write;
4822 std::io::stdout()
4823 .write_all(&bytes)
4824 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to write: {}", e)))?;
4825 Ok(true)
4826 }
4827 None => Err(CliError::FileNotFound {
4828 path: PathBuf::from(path),
4829 }),
4830 }
4831}
4832
4833/// `atomic insert preview` over PreviewMutation (InsertPreview).
4834pub fn insert_preview(

Callers 1

runMethod · 0.85

Calls 6

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

Tested by

no test coverage detected