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

Method exact_metadata

atomic-repository/src/worktree_presence.rs:53–73  ·  view source on GitHub ↗

Metadata of `relative` when every component of the path exists on disk under its exact name and every ancestor is a real directory. Returns `Ok(None)` when any component is missing, differs by case, or sits behind a symlinked or regular-file ancestor. A component matches an entry that differs only in Unicode normalization, and the walk continues under the entry's own spelling. Symlinks are never

(&mut self, relative: &Path)

Source from the content-addressed store, hash-verified

51 /// followed; the final component's own metadata is returned as-is (a
52 /// symlink reports itself).
53 pub fn exact_metadata(&mut self, relative: &Path) -> io::Result<Option<fs::Metadata>> {
54 let mut current = self.root.clone();
55 for component in relative.components() {
56 let Component::Normal(name) = component else {
57 return Ok(None);
58 };
59 let spelled = self
60 .listing(&current)?
61 .and_then(|listing| listing.spelling_of(name))
62 .map(OsStr::to_os_string);
63 let Some(spelled) = spelled else {
64 return Ok(None);
65 };
66 current.push(spelled);
67 }
68 match fs::symlink_metadata(&current) {
69 Ok(metadata) => Ok(Some(metadata)),
70 Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(None),
71 Err(error) => Err(error),
72 }
73 }
74
75 fn listing(&mut self, directory: &Path) -> io::Result<Option<&DirectoryListing>> {
76 let listing = match self.listings.entry(directory.to_path_buf()) {

Calls 6

componentsMethod · 0.80
listingMethod · 0.80
spelling_ofMethod · 0.80
cloneMethod · 0.45
pushMethod · 0.45
kindMethod · 0.45