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

Function reindex_working_copy

atomic-cli/src/commands/git/import.rs:2042–2079  ·  view source on GitHub ↗
(repo: &Repository, working_copy: WorkingCopyId)

Source from the content-addressed store, hash-verified

2040}
2041
2042fn reindex_working_copy(repo: &Repository, working_copy: WorkingCopyId) {
2043 use atomic_core::types::Hash;
2044 let started = std::time::Instant::now();
2045 use std::time::SystemTime;
2046
2047 let repo_root = repo.root().to_path_buf();
2048 let tracked = repo.list_tracked_files().unwrap_or_default();
2049 let mut entries: Vec<(String, i64, u32, u64, Hash)> = Vec::new();
2050
2051 for file in &tracked {
2052 let path = file.path.to_string_lossy();
2053 let abs = repo_root.join(super::parallel::canonical_tree_path(&path));
2054 if let Ok(metadata) = std::fs::metadata(&abs) {
2055 let mtime = metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH);
2056 let duration = mtime
2057 .duration_since(SystemTime::UNIX_EPOCH)
2058 .unwrap_or_default();
2059 if let Ok(bytes) = std::fs::read(&abs) {
2060 entries.push((
2061 path.into_owned(),
2062 duration.as_secs() as i64,
2063 duration.subsec_nanos(),
2064 metadata.len(),
2065 Hash::of(&bytes),
2066 ));
2067 }
2068 }
2069 }
2070
2071 if !entries.is_empty() {
2072 let _ = repo.update_file_index(working_copy, &entries);
2073 }
2074 trace_git_import(format!(
2075 "reindex working copy: {:?} (files={})",
2076 started.elapsed(),
2077 entries.len()
2078 ));
2079}
2080
2081/// Create .atomicignore and initialize vault AFTER git import + materialize.
2082///

Callers 1

run_importMethod · 0.85

Calls 11

canonical_tree_pathFunction · 0.85
trace_git_importFunction · 0.85
list_tracked_filesMethod · 0.80
metadataFunction · 0.50
readFunction · 0.50
rootMethod · 0.45
modifiedMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45
is_emptyMethod · 0.45
update_file_indexMethod · 0.45

Tested by

no test coverage detected