(repo: &Repository, working_copy: WorkingCopyId)
| 2040 | } |
| 2041 | |
| 2042 | fn 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 | /// |
no test coverage detected