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