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

Method materialize_view_to

atomic-repository/src/repository/sandbox.rs:205–223  ·  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

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