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

Method materialize_view_to

atomic-repository/src/repository/sandbox.rs:206–224  ·  view source on GitHub ↗

Materialize a view's visible file content into `dir` (created if needed). Writes each visible file's bytes exactly as they appear on `view` (the view's own changes plus its parent chain). Returns the number of files written.

(&self, view: &str, dir: &Path)

Source from the content-addressed store, hash-verified

204 /// view's own changes plus its parent chain). Returns the number of files
205 /// written.
206 pub fn materialize_view_to(&self, view: &str, dir: &Path) -> Result<usize, RepositoryError> {
207 std::fs::create_dir_all(dir)?;
208
209 let mut count = 0usize;
210 for path in self.visible_file_paths(view)? {
211 let bytes = match self.get_file_content_on_view(&path, view)? {
212 Some(bytes) => bytes,
213 None => continue,
214 };
215 let target = dir.join(&path);
216 if let Some(parent) = target.parent() {
217 std::fs::create_dir_all(parent)?;
218 }
219 std::fs::write(&target, &bytes)?;
220 count += 1;
221 }
222
223 Ok(count)
224 }
225
226 /// Produce a two-layer OCI image: a base layer (the `base_view`
227 /// materialized) plus a thin delta layer (files that differ on `view`

Callers 3

stageMethod · 0.80
sealMethod · 0.80

Calls 4

writeFunction · 0.85
visible_file_pathsMethod · 0.80
parentMethod · 0.80

Tested by 1