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

Function reindex_working_copy

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

Source from the content-addressed store, hash-verified

1980}
1981
1982fn reindex_working_copy(repo: &Repository, working_copy: WorkingCopyId) {
1983 use atomic_core::types::Hash;
1984 let started = std::time::Instant::now();
1985 use std::time::SystemTime;
1986
1987 let repo_root = repo.root().to_path_buf();
1988 let tracked = repo.list_tracked_files().unwrap_or_default();
1989 let mut entries: Vec<(String, i64, u32, u64, Hash)> = Vec::new();
1990
1991 for file in &tracked {
1992 let path = file.path.to_string_lossy();
1993 let abs = repo_root.join(super::parallel::canonical_tree_path(&path));
1994 if let Ok(metadata) = std::fs::metadata(&abs) {
1995 let mtime = metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH);
1996 let duration = mtime
1997 .duration_since(SystemTime::UNIX_EPOCH)
1998 .unwrap_or_default();
1999 if let Ok(bytes) = std::fs::read(&abs) {
2000 entries.push((
2001 path.into_owned(),
2002 duration.as_secs() as i64,
2003 duration.subsec_nanos(),
2004 metadata.len(),
2005 Hash::of(&bytes),
2006 ));
2007 }
2008 }
2009 }
2010
2011 if !entries.is_empty() {
2012 let _ = repo.update_file_index(working_copy, &entries);
2013 }
2014 trace_git_import(format!(
2015 "reindex working copy: {:?} (files={})",
2016 started.elapsed(),
2017 entries.len()
2018 ));
2019}
2020
2021/// Create .atomicignore and initialize vault AFTER git import + materialize.
2022///

Callers 1

run_importMethod · 0.85

Calls 10

canonical_tree_pathFunction · 0.85
trace_git_importFunction · 0.85
list_tracked_filesMethod · 0.80
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