Skip to content

Commit fbd5648

Browse files
committed
Fixes to allowing missing file / folders for cached artifacts during build, correcting an issue described here: rust-lang#57958
1 parent 35d22f4 commit fbd5648

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/librustc_incremental/persist/fs.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,10 @@ fn all_except_most_recent(
927927
fn safe_remove_dir_all(p: &Path) -> io::Result<()> {
928928
if p.exists() {
929929
let canonicalized = p.canonicalize()?;
930-
std_fs::remove_dir_all(canonicalized)
930+
match std_fs::remove_dir_all(canonicalized) {
931+
Err(ref err) if err.kind() == io::ErrorKind::NotFound => Ok(()),
932+
result => result,
933+
}
931934
} else {
932935
Ok(())
933936
}

src/librustc_incremental/persist/load.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ impl LoadResult<(PreviousDepGraph, WorkProductMap)> {
3939
}
4040
LoadResult::DataOutOfDate => {
4141
if let Err(err) = delete_all_session_dir_contents(sess) {
42-
sess.err(&format!(
43-
"Failed to delete invalidated or incompatible \
42+
sess.warn(&format!("Failed to delete invalidated or incompatible \
4443
incremental compilation session directory contents `{}`: {}.",
4544
dep_graph_path(sess).display(),
4645
err

src/librustc_incremental/persist/save.rs

+16
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,22 @@ where
119119
}
120120
}
121121

122+
let folder_path = path_buf.parent().unwrap();
123+
124+
if !folder_path.exists() {
125+
match fs::create_dir_all(&folder_path) {
126+
Ok(()) => {
127+
debug!("save: created new dep-graph folder");
128+
}
129+
Err(err) => {
130+
sess.warn(&format!("failed to create missing directory for dep-graph `{}`: {}",
131+
path_buf.display(),
132+
err));
133+
return;
134+
}
135+
}
136+
}
137+
122138
// generate the data in a memory buffer
123139
let mut encoder = Encoder::new(Vec::new());
124140
file_format::write_file_header(&mut encoder);

0 commit comments

Comments
 (0)