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

Function collect

libatomic/tests/record_service_test.rs:360–377  ·  view source on GitHub ↗
(
        root: &std::path::Path,
        dir: &std::path::Path,
        out: &mut std::collections::BTreeMap<String, Vec<u8>>,
    )

Source from the content-addressed store, hash-verified

358
359fn persistent_files(root: &std::path::Path) -> std::collections::BTreeMap<String, Vec<u8>> {
360 fn collect(
361 root: &std::path::Path,
362 dir: &std::path::Path,
363 out: &mut std::collections::BTreeMap<String, Vec<u8>>,
364 ) {
365 for entry in std::fs::read_dir(dir).unwrap() {
366 let entry = entry.unwrap();
367 let path = entry.path();
368 if entry.file_type().unwrap().is_dir() {
369 collect(root, &path, out);
370 } else {
371 out.insert(
372 path.strip_prefix(root).unwrap().display().to_string(),
373 std::fs::read(path).unwrap(),
374 );
375 }
376 }
377 }
378 let mut files = std::collections::BTreeMap::new();
379 collect(root, &root.join(".atomic"), &mut files);
380 files

Callers 1

persistent_filesFunction · 0.70

Calls 6

is_dirMethod · 0.80
displayMethod · 0.80
readFunction · 0.50
unwrapMethod · 0.45
pathMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected