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

Method materialize_view_to

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

225 /// view's own changes plus its parent chain). Returns the number of files
226 /// written.
227 pub fn materialize_view_to(&self, view: &str, dir: &Path) -> Result<usize, RepositoryError> {
228 std::fs::create_dir_all(dir)?;
229
230 let mut count = 0usize;
231 for path in self.visible_file_paths(view)? {
232 let bytes = match self.get_file_content_on_view(&path, view)? {
233 Some(bytes) => bytes,
234 None => continue,
235 };
236 let target = dir.join(&path);
237 if let Some(parent) = target.parent() {
238 std::fs::create_dir_all(parent)?;
239 }
240 std::fs::write(&target, &bytes)?;
241 count += 1;
242 }
243
244 Ok(count)
245 }
246
247 /// Produce a two-layer OCI image: a base layer (the `base_view`
248 /// 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