Populate the file index for all tracked files after a materialize. Stats each tracked file from disk and stores its mtime + size + content hash in the pristine database. Errors are silently ignored (best-effort). Why we ignore `result.file_results` and walk the tracked set: the `MaterializeResult.file_results` map is only populated when `merge_file_result(_, store_result=true)` is called, and th
(&self, _result: &MaterializeResult)
| 992 | /// view's recorded state — every tracked file's on-disk content is |
| 993 | /// the authoritative baseline FILE_INDEX should cache. |
| 994 | fn populate_file_index(&self, _result: &MaterializeResult) { |
| 995 | use std::time::SystemTime; |
| 996 | |
| 997 | let tracked = match self.list_tracked_files() { |
| 998 | Ok(t) => t, |
| 999 | Err(_) => return, |
| 1000 | }; |
| 1001 | |
| 1002 | let mut entries: Vec<(String, i64, u32, u64, Hash)> = Vec::with_capacity(tracked.len()); |
| 1003 | |
| 1004 | for file in &tracked { |
| 1005 | let abs_path = self.root.join(&file.path); |
| 1006 | let metadata = match std::fs::metadata(&abs_path) { |
| 1007 | Ok(m) if m.is_file() => m, |
| 1008 | _ => continue, |
| 1009 | }; |
| 1010 | |
| 1011 | let mtime = metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH); |
| 1012 | let duration = mtime |
| 1013 | .duration_since(SystemTime::UNIX_EPOCH) |
| 1014 | .unwrap_or_default(); |
| 1015 | let secs = duration.as_secs() as i64; |
| 1016 | let nanos = duration.subsec_nanos(); |
| 1017 | let size = metadata.len(); |
| 1018 | |
| 1019 | let content_hash = match std::fs::read(&abs_path) { |
| 1020 | Ok(bytes) => Hash::of(&bytes), |
| 1021 | Err(_) => continue, |
| 1022 | }; |
| 1023 | |
| 1024 | let normalized = file.path.to_string_lossy().replace('\\', "/"); |
| 1025 | entries.push((normalized, secs, nanos, size, content_hash)); |
| 1026 | } |
| 1027 | |
| 1028 | if !entries.is_empty() { |
| 1029 | let _ = self.update_file_index(&entries); |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | /// Update FILE_INDEX for a specific set of paths. |
| 1034 | /// |
no test coverage detected