ignore file not found when creating a snapshot

Summary:
Sometimes hg might recognise an untracked file as being added, but by the time it tries to load it, the file is gone, causing a crash.

For snapshots, it should be fine in this case to simply ignore this file. That is what this diff does. It specifically ignores `FileNotFoundError`, meaning other files still get classified as errors and we're not swallowing anything we shouldn't be.

Reviewed By: mitrandir77

Differential Revision: D34043083

fbshipit-source-id: cec7d528652c1704f3a3db707eafc0e43f24ac74
This commit is contained in:
Yan Soares Couto 2022-02-08 06:59:01 -08:00 committed by Facebook GitHub Bot
parent be5ddc9607
commit 3312f2c3cb

View File

@ -103,6 +103,14 @@ pub async fn upload_snapshot(
load_files(&root, rel_path.clone(), file_type, tracked)
.with_context(|| anyhow::anyhow!("Failed to load file {}", rel_path))
})
// Let's ignore file not found errors, they might come from transient files that disappeared.
.filter_map(|res| match res {
Ok(ok) => Some(Ok(ok)),
Err(err) => match err.downcast_ref::<std::io::Error>() {
Some(io_error) if io_error.kind() == std::io::ErrorKind::NotFound => None,
_ => Some(Err(err)),
},
})
.collect::<Result<Vec<_>, _>>()?
.into_iter()
.unzip();