Skip to content

Commit

Permalink
Do not error if the CACHEDIR.TAG file exists but cannot be written …
Browse files Browse the repository at this point in the history
…to (#7550)

Attempting to address the error in
#7434 — it seems overkill to fail
if the file exists but isn't writable.
  • Loading branch information
zanieb committed Sep 19, 2024
1 parent 99d57ca commit 5206a33
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/uv-fs/src/cachedir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ pub fn add_tag<P: AsRef<path::Path>>(directory: P) -> io::Result<()> {
/// Will return an error if The tag file doesn't exist and can't be created for any reason
/// (the `directory` doesn't exist, permission error, can't write to the file etc.).
pub fn ensure_tag<P: AsRef<path::Path>>(directory: P) -> io::Result<()> {
match add_tag(directory) {
match add_tag(&directory) {
Err(e) => match e.kind() {
io::ErrorKind::AlreadyExists => Ok(()),
// If it exists, but we can't write to it for some reason don't fail
io::ErrorKind::PermissionDenied if directory.as_ref().join("CACHEDIR.TAG").exists() => {
Ok(())
}
_ => Err(e),
},
other => other,
Expand Down

0 comments on commit 5206a33

Please sign in to comment.