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

Function reindex_working_copy

atomic-cli/src/commands/git/import.rs:600–630  ·  view source on GitHub ↗

Rebuild FILE_INDEX from the current working copy. During normal single-branch Git import the files on disk are already the authoritative Git checkout for the imported branch, so there is no reason to materialize the same content back out of Atomic. Indexing the tracked files makes the post-import `atomic status` baseline clean.

(repo: &Repository)

Source from the content-addressed store, hash-verified

598/// to materialize the same content back out of Atomic. Indexing the tracked
599/// files makes the post-import `atomic status` baseline clean.
600fn reindex_working_copy(repo: &Repository) {
601 use atomic_core::types::Hash;
602 use std::time::SystemTime;
603
604 let repo_root = repo.root().to_path_buf();
605 let tracked = repo.list_tracked_files().unwrap_or_default();
606 let mut entries: Vec<(String, i64, u32, u64, Hash)> = Vec::new();
607
608 for file in &tracked {
609 let abs = repo_root.join(&file.path);
610 if let Ok(metadata) = std::fs::metadata(&abs) {
611 let mtime = metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH);
612 let duration = mtime
613 .duration_since(SystemTime::UNIX_EPOCH)
614 .unwrap_or_default();
615 if let Ok(bytes) = std::fs::read(&abs) {
616 entries.push((
617 file.path.to_string_lossy().replace('\\', "/"),
618 duration.as_secs() as i64,
619 duration.subsec_nanos(),
620 metadata.len(),
621 Hash::of(&bytes),
622 ));
623 }
624 }
625 }
626
627 if !entries.is_empty() {
628 let _ = repo.update_file_index(&entries);
629 }
630}
631
632/// Create .atomicignore and initialize vault AFTER git import + materialize.
633///

Callers 1

runMethod · 0.85

Calls 8

list_tracked_filesMethod · 0.80
rootMethod · 0.45
modifiedMethod · 0.45
pushMethod · 0.45
replaceMethod · 0.45
lenMethod · 0.45
is_emptyMethod · 0.45
update_file_indexMethod · 0.45

Tested by

no test coverage detected