Skip to content

Commit 5abef94

Browse files
ahayzen-kdabsylvestre
authored andcommitted
lru: do not fail removing file if already removed
Closes #2092
1 parent e42fa94 commit 5abef94

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/lru_disk_cache/mod.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,22 @@ impl LruDiskCache {
225225
//TODO: check that files are removable during `init`, so that this is only
226226
// due to outside interference.
227227
fs::remove_file(&remove_path).unwrap_or_else(|e| {
228-
panic!("Error removing file from cache: `{:?}`: {}", remove_path, e)
228+
// Sometimes the file has already been removed
229+
// this seems to happen when the max cache size has been reached
230+
// https://github.com/mozilla/sccache/issues/2092
231+
if e.kind() == std::io::ErrorKind::NotFound {
232+
debug!(
233+
"Error removing file from cache as it was not found: `{:?}`",
234+
remove_path
235+
);
236+
} else {
237+
panic!(
238+
"Error removing file from cache: `{:?}`: {}, {:?}",
239+
remove_path,
240+
e,
241+
e.kind()
242+
)
243+
}
229244
});
230245
}
231246
Ok(())

0 commit comments

Comments
 (0)