comparison rust/hg-core/src/dirstate_tree/status.rs @ 48774:dcec16e799dd stable 6.0.3

status: fix hg status race against file deletion Differential Revision: https://phab.mercurial-scm.org/D12202
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Thu, 17 Feb 2022 20:50:04 +0000
parents 83d0bd45b662
children 834c938227c6
comparison
equal deleted inserted replaced
48748:2d6940811067 48774:dcec16e799dd
711 /// list instead. 711 /// list instead.
712 fn read_dir(path: &Path, is_at_repo_root: bool) -> io::Result<Vec<Self>> { 712 fn read_dir(path: &Path, is_at_repo_root: bool) -> io::Result<Vec<Self>> {
713 let mut results = Vec::new(); 713 let mut results = Vec::new();
714 for entry in path.read_dir()? { 714 for entry in path.read_dir()? {
715 let entry = entry?; 715 let entry = entry?;
716 let metadata = entry.metadata()?; 716 let metadata = match entry.metadata() {
717 Ok(v) => v,
718 Err(e) => {
719 // race with file deletion?
720 if e.kind() == std::io::ErrorKind::NotFound {
721 continue;
722 } else {
723 return Err(e);
724 }
725 }
726 };
717 let name = get_bytes_from_os_string(entry.file_name()); 727 let name = get_bytes_from_os_string(entry.file_name());
718 // FIXME don't do this when cached 728 // FIXME don't do this when cached
719 if name == b".hg" { 729 if name == b".hg" {
720 if is_at_repo_root { 730 if is_at_repo_root {
721 // Skip the repo’s own .hg (might be a symlink) 731 // Skip the repo’s own .hg (might be a symlink)